website/.forgejo/workflows/build.yml

48 lines
1.5 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:
deploy:
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: 🐋 Build Container
run: |
2024-04-03 10:32:42 +00:00
# extract tag name without the prefix
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: |
echo "${{ secrets.PUBLISH_TOKEN }}" | docker login gitpot.dev -u sangelo --password-stdin
2024-04-03 10:32:42 +00:00
docker push "gitpot.dev/sangelo/website:${TAG}"
2024-04-03 09:05:30 +00:00
# publish tag latest as well
if [[ "${{ github.ref }}" == "refs/tags/"* ]]; then
2024-04-03 10:32:42 +00:00
docker tag "gitpot.dev/sangelo/website:${TAG}" "gitpot.dev/sangelo/website:latest"
docker push "gitpot.dev/sangelo/website:latest"
2024-04-03 09:05:30 +00:00
fi