2024-04-03 09:05:30 +00:00
|
|
|
name: Build and push docker image
|
|
|
|
|
|
|
|
# start workflow every time a tag/release is created
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- '*'
|
|
|
|
|
|
|
|
jobs:
|
2024-04-16 12:15:44 +00:00
|
|
|
publish:
|
2024-04-03 09:05:30 +00:00
|
|
|
runs-on: ubuntu-latest
|
2024-04-03 09:25:12 +00:00
|
|
|
container:
|
|
|
|
image: ghcr.io/catthehacker/ubuntu:act-latest
|
2024-04-03 09:44:00 +00:00
|
|
|
volumes:
|
|
|
|
- /var/run/docker.sock:/var/run/docker.sock
|
2024-04-03 09:05:30 +00:00
|
|
|
defaults:
|
|
|
|
run:
|
2024-04-03 09:13:50 +00:00
|
|
|
working-directory: /tmp
|
2024-04-03 09:05:30 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2024-06-03 19:11:39 +00:00
|
|
|
- name: ⚙️ Update website debug info
|
2024-06-03 18:51:22 +00:00
|
|
|
run: |
|
2024-06-03 18:56:36 +00:00
|
|
|
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
|
|
|
|
export SHA=$(echo "${{ github.sha }}")
|
2024-06-03 19:05:45 +00:00
|
|
|
sed -i "s|\"commit\": \"\"|\"commit\": \"$SHA\"|" /workspace/sangelo/website/static/assets/debug.json
|
2024-06-03 19:02:59 +00:00
|
|
|
sed -i "s|\"tag\": \"\"|\"tag\": \"$TAG\"|" /workspace/sangelo/website/static/assets/debug.json
|
2024-06-03 18:51:22 +00:00
|
|
|
|
2024-04-03 09:05:30 +00:00
|
|
|
- name: 🐋 Build Container
|
|
|
|
run: |
|
2024-04-03 10:32:42 +00:00
|
|
|
# extract tag name without the prefix
|
2024-04-03 10:39:23 +00:00
|
|
|
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
|
2024-04-03 09:05:30 +00:00
|
|
|
# build the container
|
2024-04-03 10:32:42 +00:00
|
|
|
just -f /workspace/sangelo/website/Justfile build "${TAG}"
|
2024-04-03 09:05:30 +00:00
|
|
|
|
|
|
|
- name: 🐳 Publish Container
|
|
|
|
run: |
|
2024-04-03 10:43:07 +00:00
|
|
|
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
|
2024-04-08 11:52:10 +00:00
|
|
|
echo "${{ secrets.PUBLISH_TOKEN }}" | docker login gitpot.org -u sangelo --password-stdin
|
|
|
|
docker push "gitpot.org/sangelo/website:${TAG}"
|
2024-04-03 09:05:30 +00:00
|
|
|
|
|
|
|
# publish tag latest as well
|
2024-04-03 10:46:25 +00:00
|
|
|
if echo "${{ github.ref }}" | grep -q "refs/tags/"; then
|
2024-04-08 11:52:10 +00:00
|
|
|
docker tag "gitpot.org/sangelo/website:${TAG}" "gitpot.org/sangelo/website:latest"
|
|
|
|
docker push "gitpot.org/sangelo/website:latest"
|
2024-04-03 09:05:30 +00:00
|
|
|
fi
|