Skip to content

Commit

Permalink
[docker] Fix docker trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Feb 9, 2024
1 parent 4aef35a commit acae954
Showing 1 changed file with 30 additions and 13 deletions.
43 changes: 30 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ jobs:

runs-on: ubuntu-latest

outputs:
commit-message: ${{ steps.get-commit-message.outputs.message }}

env:
SBT_OPTS: >
-Xms2048m
Expand Down Expand Up @@ -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/[email protected]
Expand All @@ -138,42 +147,45 @@ 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
with:
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
with:
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: >
Expand Down Expand Up @@ -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/[email protected]
Expand All @@ -232,40 +250,40 @@ 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
with:
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
with:
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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit acae954

Please sign in to comment.