website/.forgejo/workflows/build.yml

59 lines
2.4 KiB
YAML
Raw Permalink 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 website debug info
run: |
2024-06-03 18:56:36 +00:00
export TAG=$(echo "${{ github.ref }}" | sed 's/refs\/tags\///')
export SHA=$(echo "${{ github.sha }}")
echo 'sed -i "s|\"commit\": \"unavailable\"|\"commit\": \"$SHA\"|" /workspace/sangelo/website/static/assets/debug.json'
2024-06-05 07:59:06 +00:00
sed -i "s|\"commit\": \"unavailable\"|\"commit\": \"$SHA\"|" /workspace/sangelo/website/static/assets/debug.json || echo "Failed to plant debug info into debug.json. (commit hash)"
echo 'sed -i "s|\"tag\": \"unavailable\"|\"tag\": \"$TAG\"|" /workspace/sangelo/website/static/assets/debug.json'
2024-06-05 07:59:06 +00:00
sed -i "s|\"tag\": \"unavailable\"|\"tag\": \"$TAG\"|" /workspace/sangelo/website/static/assets/debug.json || echo "Failed to plant debug info into debug.json. (git tag)"
2024-06-05 07:09:48 +00:00
echo "Successfully planted debug info into 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