From acae954503261196526e60d7ef9f594f9e53e920 Mon Sep 17 00:00:00 2001 From: Daniel Slapman Date: Fri, 9 Feb 2024 09:25:47 +0100 Subject: [PATCH] [docker] Fix docker trigger --- .github/workflows/ci.yml | 43 ++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 007e65e5..3eea99cc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -87,6 +87,9 @@ jobs: runs-on: ubuntu-latest + outputs: + commit-message: ${{ steps.get-commit-message.outputs.message }} + env: SBT_OPTS: > -Xms2048m @@ -120,6 +123,12 @@ jobs: version: "25.2" repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Get commit message + id: get-commit-message + run: | + message="$(git log -1 --pretty=format:'%s')" + echo "message=$message" >> "$GITHUB_OUTPUT" + - name: Get the Ref id: get-ref uses: ankitvgupta/ref-to-tag-action@v1.0.1 @@ -138,7 +147,7 @@ jobs: context: ./backend/mockingbird-api/target/docker/stage push: false tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }} - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} - name: Log in to the Container registry uses: docker/login-action@v3 @@ -146,7 +155,7 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} + if: ${{ github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') }} - name: Build and push docker image uses: docker/build-push-action@v5 @@ -154,26 +163,29 @@ jobs: context: ./backend/mockingbird-api/target/docker/stage push: true tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }} - if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} + if: ${{ github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') }} - name: Save docker image to file run: | docker save -o /tmp/image-jvm.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_JVM }} gzip /tmp/image-jvm.tar - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} - name: Upload image with JVM mockingbird uses: actions/upload-artifact@v4 with: name: image-jvm path: /tmp/image-jvm.tar.gz - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} back-build-native: needs: [front-build] runs-on: ubuntu-22.04 + outputs: + commit-message: ${{ steps.get-commit-message.outputs.message }} + env: CI: true SBT_OPTS: > @@ -209,6 +221,12 @@ jobs: version: "25.2" repo-token: ${{ secrets.GITHUB_TOKEN }} + - name: Get commit message + id: get-commit-message + run: | + message="$(git log -1 --pretty=format:'%s')" + echo "message=$message" >> "$GITHUB_OUTPUT" + - name: Get the Ref id: get-ref uses: ankitvgupta/ref-to-tag-action@v1.0.1 @@ -232,7 +250,7 @@ jobs: context: ./backend/mockingbird-native/target/docker/stage push: false tags: ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }} - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} - name: Log in to the Container registry uses: docker/login-action@v3 @@ -240,7 +258,7 @@ jobs: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} + if: ${{ github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') }} - name: Build and push docker image uses: docker/build-push-action@v5 @@ -248,24 +266,24 @@ jobs: context: ./backend/mockingbird-native/target/docker/stage push: true tags: ghcr.io/leviysoft/mockingbird:${{ steps.get-ref.outputs.tag }}-native - if: ${{ github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') }} + if: ${{ github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') }} - name: Save docker image to file run: | docker save -o /tmp/image-native.tar ${{ env.MOCKINGBIRD_TEST_IMAGE_NATIVE }} gzip /tmp/image-native.tar - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} - name: Upload image with native mockingbird uses: actions/upload-artifact@v4 with: name: image-native path: /tmp/image-native.tar.gz - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} + if: ${{ ! ( github.ref_type == 'tag' || startsWith(steps.get-commit-message.outputs.message, '[docker]') ) }} test-jvm-image: - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} needs: [back-build] + if: ${{ ! ( github.ref_type == 'tag' || startsWith(needs.back-build.outputs.commit-message, '[docker]') ) }} runs-on: ubuntu-latest @@ -298,8 +316,8 @@ jobs: sbt "project examples; clean; fixCheck; test" test-native-image: - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} needs: [back-build-native] + if: ${{ ! ( github.ref_type == 'tag' || startsWith(needs.back-build-native.outputs.commit-message, '[docker]') ) }} runs-on: ubuntu-latest @@ -332,7 +350,6 @@ jobs: sbt "project examples; clean; fixCheck; test" test-example-dsl: - if: ${{ ! ( github.ref_type == 'tag' || startsWith(github.event.head_commit.message, '[docker]') ) }} runs-on: ubuntu-latest steps: