website/.forgejo/workflows/build.yml

56 lines
1.9 KiB
YAML
Raw Normal View History

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:
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
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
- name: Update debug.json with Git info
run: |
2024-06-03 18:56:36 +00:00
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
export SHA=$(echo "${{ github.sha }}")
sed -i "s|\"commit\": \"\"|\"commit\": \"$SHA\"|" static/assets/debug.json
sed -i "s|\"tag\": \"\"|\"tag\": \"$TAG\"|" static/assets/debug.json
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: |
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
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