Workflow file for this run
This file contains 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: Upload Docker image to Docker Hub | |
on: | |
release: | |
types: [published] | |
jobs: | |
release: | |
name: Upload Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set appVersion | |
uses: bhowell2/github-substring-action@v1 | |
id: appVersion | |
with: | |
value: ${{github.ref}} | |
index_of_str: "refs/tags/v" | |
- run: echo "Version = ${{steps.appVersion.outputs.substring}}" | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 17 | |
cache: gradle | |
- name: Package app | |
run: | | |
./gradlew shadowJar --no-daemon | |
mv build/libs/pharmcat-${{steps.appVersion.outputs.substring}}-all.jar build/pharmcat.jar | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
id: docker_build | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: pgkb/pharmcat:latest,pgkb/pharmcat:${{steps.appVersion.outputs.substring}} | |
- name: Send Slack notification on failure | |
if: failure() | |
uses: slackapi/slack-github-action@v1 | |
with: | |
channel-id: 'dev' | |
payload: | | |
{ | |
"attachments": [{ | |
"color": "#ff0000", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": ":stop: <https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|FAILED ${{ github.workflow }}!>" | |
} | |
}, | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "Triggered by ${{ github.event_name }} on <${{ github.event.pull_request.html_url || github.event.head_commit.url }}|${{ github.ref_name }}> by ${{ github.actor }}." | |
} | |
}, | |
{ | |
"type": "context", | |
"elements": [ | |
{ | |
"type": "mrkdwn", | |
"text": "Last commit:\n${{ github.event.head_commit.message }}" | |
} | |
] | |
} | |
] | |
}] | |
} | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_NOTIFICATIONS_BOT_TOKEN }} |