From 6c6171558cc7fdbdf5e2f23c48a3e2a76149686b Mon Sep 17 00:00:00 2001 From: Altonhe Date: Thu, 14 Mar 2024 13:40:24 -0400 Subject: [PATCH] feat: build and push tagged image upon a new release --- .github/workflows/docker.yaml | 47 +++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/.github/workflows/docker.yaml b/.github/workflows/docker.yaml index 6eb1f39..a5bc004 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/docker.yaml @@ -3,9 +3,12 @@ on: push: branches: - main + release: + types: [ published ] jobs: buildx: + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} runs-on: ubuntu-latest strategy: matrix: @@ -50,3 +53,47 @@ jobs: tags: | opentransitsoftwarefoundation/${{ matrix.name }}:latest opentransitsoftwarefoundation/${{ matrix.name }}:${{ github.sha }} + + buildx-release: + if: ${{ github.event_name == 'release' }} + runs-on: ubuntu-latest + strategy: + matrix: + context: [ bundler, oba ] + include: + - name: onebusaway-bundle-builder + context: bundler + - name: onebusaway-api-webapp + context: oba + steps: + - name: Compute image tag name + run: echo "IMAGE_TAG=$(echo $GITHUB_REF_NAME)" >> $GITHUB_ENV + - name: Checkout code + uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: linux/amd64,linux/arm64,linux/arm/v7 + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + - name: Inspect builder + run: | + echo "Name: ${{ steps.buildx.outputs.name }}" + echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}" + echo "Status: ${{ steps.buildx.outputs.status }}" + echo "Flags: ${{ steps.buildx.outputs.flags }}" + echo "Platforms: ${{ steps.buildx.outputs.platforms }}" + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Build and push images + uses: docker/build-push-action@v5 + with: + context: ${{ matrix.context }} + platforms: linux/amd64,linux/arm64,linux/arm/v7 + push: true + tags: | + opentransitsoftwarefoundation/${{ matrix.name }}:${{ env.IMAGE_TAG }}