updated build system #12
This file contains hidden or 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: CI | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| workflow_dispatch: | |
| env: | |
| REGISTRY: ghcr.io | |
| BINGO_FRONTEND_IMAGE_NAME: ${{ github.repository }}-bingo-fe | |
| BINGO_BE_IMAGE_NAME: ${{ github.repository }}-bingo-be | |
| jobs: | |
| docker-build: | |
| permissions: | |
| contents: read | |
| packages: write | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| image: [bingo-fe, bingo-be] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Extract version or set default | |
| id: get_version | |
| shell: bash | |
| run: | | |
| VERSION=$(git describe --tags --abbrev=0 --always) | |
| if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+-(alpha|beta) ]]; then | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| else | |
| echo "version=latest" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v2 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v2 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v2 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Cache Docker layers | |
| uses: actions/cache@v4 | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ matrix.image }}-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx-${{ matrix.image }}- | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v4 | |
| with: | |
| context: ./packages/${{ matrix.image }} | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/bingo-simulator-${{ matrix.image }}:${{ steps.get_version.outputs.version }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| cache-from: type=local,src=/tmp/.buildx-cache | |
| cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max | |
| - name: Move cache | |
| run: | | |
| rm -rf /tmp/.buildx-cache | |
| mv /tmp/.buildx-cache-new /tmp/.buildx-cache |