Skip to content

feat: swarm updates (#204) #51

feat: swarm updates (#204)

feat: swarm updates (#204) #51

Workflow file for this run

name: Build images
on:
push:
tags:
- '*'
jobs:
setup:
runs-on: ubuntu-latest
outputs:
repo_name: ${{ steps.set_repo_name.outputs.repo_name }}
image_tag: ${{ steps.set_image_tag.outputs.image_tag }}
steps:
- id: set_repo_name
run: echo "repo_name=$(echo "${{ github.repository }}" | cut -d'/' -f2)" >> $GITHUB_OUTPUT
- id: set_image_tag
run: echo "image_tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
build-and-push:
runs-on: ubuntu-latest
needs: setup
strategy:
matrix:
image:
- name: gba-postgres
directory: ./postgres
build_arg_name: PG_DB_USER
- name: gba-webserver
directory: ./gbajs3
build_arg_name: CLIENT_HOST
- name: gba-auth-server
directory: ./auth
- name: gba-admin-server
directory: ./admin
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Login to Registry
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build
env:
REPO_NAME: ${{ needs.setup.outputs.repo_name }}
IMAGE_TAG: ${{ needs.setup.outputs.image_tag }}
BUILD_ARG_NAME: ${{ matrix.image.build_arg_name }}
BUILD_ARG_VALUE: ${{ secrets[matrix.image.build_arg_name] || '' }}
run: |
if [ -n "$BUILD_ARG_NAME" ] && [ -n "$BUILD_ARG_VALUE" ]; then
docker build --build-arg $BUILD_ARG_NAME=$BUILD_ARG_VALUE \
-t ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:${IMAGE_TAG} \
-t ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:latest \
${{ matrix.image.directory }}
else
docker build -t ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:${IMAGE_TAG} \
-t ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:latest \
${{ matrix.image.directory }}
fi
- name: Push
env:
REPO_NAME: ${{ needs.setup.outputs.repo_name }}
IMAGE_TAG: ${{ needs.setup.outputs.image_tag }}
run: |
docker push ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:${IMAGE_TAG}
docker push ghcr.io/${{ github.actor }}/${REPO_NAME}/${{ matrix.image.name }}:latest