Skip to content

feat: additional shepherd config #41

feat: additional shepherd config

feat: additional shepherd config #41

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: Set postgres arg
if: matrix.image.build_arg_name == 'PG_DB_USER'
env:
BUILD_ARG_VALUE: ${{ secrets.PG_DB_USER }}
run: echo "Build argument value set for PG_DB_USER"
- name: Set webserver arg
if: matrix.image.build_arg_name == 'CLIENT_HOST'
env:
BUILD_ARG_VALUE: ${{ secrets.CLIENT_HOST }}
run: echo "Build argument value set for CLIENT_HOST"
- 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 }}
run: |
if [ -n "$BUILD_ARG_NAME" ] && [ -n "$BUILD_ARG_VALUE" ]; then
echo "Building with docker arg $BUILD_ARG_NAME"
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
echo "Building with no docker arg"
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