website/.forgejo/workflows/build.yml
Sangelo 401edbc6c4
Some checks failed
Build and push docker image / publish (push) Failing after 7s
[e] experimentally add debug information on website
2024-06-03 20:51:22 +02:00

55 lines
1.9 KiB
YAML

name: Build and push docker image
# start workflow every time a tag/release is created
on:
push:
tags:
- '*'
jobs:
publish:
runs-on: ubuntu-latest
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
defaults:
run:
working-directory: /tmp
# build the docker container
steps:
- name: ✨ Installing just command runner
run: |
# download and extract just to /bin/just
curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | bash -s -- --to /bin
just --help || echo "Error: 'just' wasn't found. Maybe the download failed?"
- name: ⬇️ Checkout Repository
uses: actions/checkout@v4
- name: Update debug.json with Git info
run: |
git rev-parse HEAD > commit_hash
git describe --tags --abbrev=0 > tag
sed -i "s|\"commit\": \"\"|\"commit\": \"$(cat commit_hash)\"|" static/assets/debug.json
sed -i "s|\"tag\": \"\"|\"tag\": \"$(cat tag)\"|" static/assets/debug.json
- name: 🐋 Build Container
run: |
# extract tag name without the prefix
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
# build the container
just -f /workspace/sangelo/website/Justfile build "${TAG}"
- name: 🐳 Publish Container
run: |
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
echo "${{ secrets.PUBLISH_TOKEN }}" | docker login gitpot.org -u sangelo --password-stdin
docker push "gitpot.org/sangelo/website:${TAG}"
# publish tag latest as well
if echo "${{ github.ref }}" | grep -q "refs/tags/"; then
docker tag "gitpot.org/sangelo/website:${TAG}" "gitpot.org/sangelo/website:latest"
docker push "gitpot.org/sangelo/website:latest"
fi