Skip to content

v5.0.1

v5.0.1 #13

Workflow file for this run

name: Publish Docker Image
on:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
- platform: linux/arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- name: Setup Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: harperfast/harper
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0
- name: Build and push by digest
id: build
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294 # v7.0.0
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=harperfast/harper,push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
digest="${{ steps.build.outputs.digest }}"
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
with:
name: digest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
merge:
runs-on: ubuntu-latest
needs: [build]
outputs:
docker-image-tag: ${{ steps.meta.outputs.version }}
steps:
- name: Download digests
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
path: /tmp/digests
pattern: digest-*
merge-multiple: true
- name: Setup Docker metadata
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: harperfast/harper
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Login to Docker Hub
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf 'harperfast/harper@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect harperfast/harper:${{ steps.meta.outputs.version }}
send-slack-message-on-success:
if: success() && !cancelled()
needs: [merge]
runs-on: ubuntu-latest
steps:
- name: Send Slack published notification
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#development-ci",
"text": "Harper v${{ needs.merge.outputs.docker-image-tag }} has been published to Docker Hub",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Harper v${{ needs.merge.outputs.docker-image-tag }} release"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Status*"
},
{
"type": "mrkdwn",
"text": ":white_check_mark: Published to :docker_logo:"
},
{
"type": "mrkdwn",
"text": "<https://hub.docker.com/layers/harperfast/harper/${{ needs.merge.outputs.docker-image-tag }}|harperfast/harper:${{ needs.merge.outputs.docker-image-tag }}>"
}
]
}
]
}
send-slack-message-on-failure:
if: failure() && !cancelled()
needs: [merge]
runs-on: ubuntu-latest
steps:
- uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
{
"channel": "#development-ci",
"text": "Harper v${{ needs.merge.outputs.docker-image-tag }} Docker publish failed",
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "Harper v${{ needs.merge.outputs.docker-image-tag }} release"
}
},
{
"type": "context",
"elements": [
{
"type": "mrkdwn",
"text": "*Status*"
},
{
"type": "mrkdwn",
"text": ":x: Failed to publish to :docker_logo:"
},
{
"type": "mrkdwn",
"text": "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Workflow run ${{ github.run_id }}>"
}
]
}
]
}