test: uncomment and use test tag #16
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.get_repo_name.outputs.repo_name }} | |
image_tag: ${{ steps.get_image_tag.outputs.image_tag }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Docker version | |
run: | | |
docker version | |
docker compose version | |
- name: Login to Registry | |
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
- name: Semver and repo information | |
id: get_repo_name | |
run: | | |
echo "::set-output name=repo_name::$(echo "${{ github.repository }}" | cut -d'/' -f2)" | |
echo "::set-output name=image_tag::${{ github.ref }}" | |
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: 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 | |
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 |