sunders/.forgejo/workflows/images.yml
ViMaSter 1e6f858426
All checks were successful
Build (and tag) Images / build (push) Successful in 35s
fix: Enables image pushing for any git branch push
2025-10-13 19:23:50 +02:00

58 lines
No EOL
1.8 KiB
YAML

name: Build (and tag) Images
on:
push:
branches:
- main
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: git.hamburg.ccc.de
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set image tags
id: vars
run: |
if [ "${{ github.ref_name }}" = "main" ] && [ "${{ github.event_name }}" = "push" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
fi
- name: Build web image
run: |
docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }} .
working-directory: ./web
- name: Build data_handler image
run: |
docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/data_handler:${{ steps.vars.outputs.tag }} .
working-directory: ./data_handler
- name: Push images to Container Registry
run: |
docker push git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }}
docker push git.hamburg.ccc.de/ccchh/sunders/data_handler:${{ steps.vars.outputs.tag }}
if: github.event_name == 'push'
- name: Update docker-compose.yml image tags
run: |
sed -i "s/:latest/:${{ steps.vars.outputs.tag }}/g" docker-compose.yml
- name: Start Docker Compose services
run: |
docker compose up -d --wait
docker compose down