feat: add additional test (#209) #52
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
build_with_tag: true | |
- 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] || '' }} | |
BUILD_WITH_TAG: ${{ matrix.image.build_with_tag }} | |
run: | | |
BUILD_ARG_FLAGS="" | |
if [ -n "$BUILD_ARG_NAME" ] && [ -n "$BUILD_ARG_VALUE" ]; then | |
BUILD_ARG_FLAGS="--build-arg $BUILD_ARG_NAME=$BUILD_ARG_VALUE" | |
if [ "$BUILD_WITH_TAG" = "true" ]; then | |
BUILD_ARG_FLAGS="$BUILD_ARG_FLAGS --build-arg RELEASE_VERSION=$IMAGE_TAG" | |
docker build $BUILD_ARG_FLAGS \ | |
-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 }} | |
- 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 |