Skip to content

chore(ci): build-test pipeline & release prebuilt images #5

chore(ci): build-test pipeline & release prebuilt images

chore(ci): build-test pipeline & release prebuilt images #5

name: template-mage-pipeline
## workflow will trigger on below condition,
## except image release that have jobs condition to trigger only on tagging
on:
pull_request:
branches:
- main
push:
branches:
- main
tags:
- 'v*.*.*'
env:
IMAGE_NAME_NAKAMA: starter-game-template-nakama
IMAGE_NAME_CARDINAL: starter-game-template-cardinal
IMAGE_NAME_TESTSUITE: starter-game-template-testsuite
jobs:
mage-build-test:
runs-on: ubuntu-latest
defaults:
run:
shell: bash
strategy:
matrix:
go-version: [1.20.x]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- name: Mage - check
uses: magefile/mage-action@v2
with:
version: latest
args: check
- name: Mage - build & test
uses: magefile/mage-action@v2
with:
version: latest
args: test
- name: Docker show build images
run: |
docker image ls -a | grep starter-game-template
- name: Docker save local build images
run: |

Check failure on line 52 in .github/workflows/backend-mage-pipeline.yaml

View workflow run for this annotation

GitHub Actions / template-mage-pipeline

Invalid workflow file

The workflow is not valid. .github/workflows/backend-mage-pipeline.yaml (Line: 52, Col: 14): Unexpected symbol: 'IMAGE_NAME_NAKAMA:latest'. Located at position 5 within expression: env.IMAGE_NAME_NAKAMA:latest
docker save ${{ env.IMAGE_NAME_NAKAMA:latest }} > /tmp/${{ env.IMAGE_NAME_NAKAMA }}-latest.tar
docker save ${{ env.IMAGE_NAME_CARDINAL:latest }} > /tmp/${{ env.IMAGE_NAME_CARDINAL }}-latest.tar
docker save ${{ env.IMAGE_NAME_TESTSUITE:latest }} > /tmp/${{ env.IMAGE_NAME_TESTSUITE }}-latest.tar
- name: Upload local build images to temporary artifact
uses: actions/upload-artifact@v3
with:
name: buildimage
path: /tmp/starter-game-template-*.tar
images-release:
runs-on: ubuntu-latest
needs: mage-build-test
# if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main'
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Download local build images artifact
uses: actions/download-artifact@v3
with:
name: buildimage
path: /tmp/
- name: Load image and show build images
run: |
docker load --input /tmp/${{ env.IMAGE_NAME_NAKAMA }}-latest.tar
docker load --input /tmp/${{ env.IMAGE_NAME_CARDINAL }}-latest.tar
docker load --input /tmp/${{ env.IMAGE_NAME_TESTSUITE }}-latest.tar
docker image ls -a | grep starter-game-template
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID_NAKAMA=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME_NAKAMA }}
IMAGE_ID_NAKAMA=$(echo $IMAGE_ID_NAKAMA | tr '[A-Z]' '[a-z]')
IMAGE_ID_CARDINAL=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME_CARDINAL }}
IMAGE_ID_CARDINAL=$(echo $IMAGE_ID_CARDINAL | tr '[A-Z]' '[a-z]')
IMAGE_ID_TESTSUITE=ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME_TESTSUITE }}
IMAGE_ID_TESTSUITE=$(echo $IMAGE_ID_TESTSUITE | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
docker tag ${{ env.IMAGE_NAME_NAKAMA }}:latest $IMAGE_ID_NAKAMA:$VERSION
docker tag ${{ env.IMAGE_NAME_CARDINAL }}:latest $IMAGE_ID_CARDINAL:$VERSION
docker tag ${{ env.IMAGE_NAME_TESTSUITE }}:latest $IMAGE_ID_TESTSUITE:$VERSION
docker push $IMAGE_ID_NAKAMA:$VERSION
docker push $IMAGE_ID_CARDINAL:$VERSION
docker push $IMAGE_ID_TESTSUITE:$VERSION
artifact-cleanup:
runs-on: ubuntu-latest
needs: [
mage-build-test,
images-release
]
if: always()
steps:
- name: Remove local build image artifact
uses: geekyeggo/delete-artifact@v2
with:
name: buildimage