refactor: Limits docker image pushing to git pushes to main branch
All checks were successful
Build (and tag) Images / build (push) Successful in 35s

This commit is contained in:
Vincent Mahnke 2025-10-13 19:19:39 +02:00
commit 3aeb91101d

View file

@ -1,4 +1,4 @@
name: Build Hello World Image
name: Build (and tag) Images
on:
push:
@ -23,26 +23,29 @@ jobs:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Set image tag
- name: Set image tags
id: vars
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
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 and push web image to Container Registry
- name: Build images
run: |
pushd ./web
docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }} .
docker push git.hamburg.ccc.de/ccchh/sunders/web:${{ steps.vars.outputs.tag }}
working-directory: ./web
- name: Build and push data_handler image to Container Registry
run: |
popd
pushd ./data_handler
docker build -f ./Containerfile -t git.hamburg.ccc.de/ccchh/sunders/data_handler:${{ steps.vars.outputs.tag }} .
popd
- 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 }}
working-directory: ./data_handler
if: github.event_name == 'push' && github.ref_name == 'main'
- name: Update docker-compose.yml image tags
run: |