From 2893d94ce7e623d5718c5ae6457829eba22cbf14 Mon Sep 17 00:00:00 2001 From: Jun Kurihara Date: Wed, 2 Aug 2023 14:58:50 +0900 Subject: [PATCH] feat: update github actions --- .github/workflows/docker_build_push.yml | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker_build_push.yml b/.github/workflows/docker_build_push.yml index deb4854..a3930c8 100644 --- a/.github/workflows/docker_build_push.yml +++ b/.github/workflows/docker_build_push.yml @@ -73,12 +73,27 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - name: Nightly build and push + - name: Nightly build test on amd64 for pull requests + if: ${{ github.event_name == 'pull_request' }} uses: docker/build-push-action@v4 with: context: . build-args: ${{ matrix.build-args }} - push: ${{ github.event_name != 'pull_request' }} + push: false + build-contexts: ${{ matrix.build-contexts }} + file: ${{ matrix.dockerfile }} + cache-from: type=gha,scope=rpxy-nightly-${{ matrix.target }} + cache-to: type=gha,mode=max,scope=rpxy-nightly-${{ matrix.target }} + platforms: linux/amd64 + labels: ${{ steps.meta.outputs.labels }} + + - name: Nightly build and push from develop branch + if: ${{ (github.ref_name == 'develop') && (github.event_name == 'push') }} + uses: docker/build-push-action@v4 + with: + context: . + build-args: ${{ matrix.build-args }} + push: true tags: | ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:nightly${{ matrix.tags-suffix }} ${{ env.DH_REGISTRY_NAME }}:nightly${{ matrix.tags-suffix }} @@ -89,17 +104,18 @@ jobs: platforms: ${{ matrix.platforms }} labels: ${{ steps.meta.outputs.labels }} - - name: Release build and push slim - if: ${{ github.ref_name == 'main' }} + - name: Release build and push from main branch + if: ${{ (github.ref_name == 'main') && (github.event_name == 'push') }} uses: docker/build-push-action@v4 with: context: . build-args: ${{ matrix.build-args }} - push: ${{ github.event_name != 'pull_request' }} + push: true tags: | ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:latest${{ matrix.tags-suffix }} ${{ env.DH_REGISTRY_NAME }}:latest${{ matrix.tags-suffix }} - ${{ matrix.aliases }} + ${{ env.GHCR }}/${{ env.GHCR_IMAGE_NAME }}:${{ matrix.aliases }} + ${{ env.DH_REGISTRY_NAME }}:${{ matrix.aliases }} build-contexts: ${{ matrix.build-contexts }} file: ${{ matrix.dockerfile }} cache-from: type=gha,scope=rpxy-latest-${{ matrix.target }}