SemVer - Tag on Data Change #432
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: 'SemVer - Tag on Data Change' | |
on: | |
workflow_dispatch: | |
inputs: | |
increment: | |
description: 'SemVer Increment Value' | |
required: true | |
type: choice | |
default: 'patch' | |
options: | |
- patch | |
- minor | |
- major | |
jobs: | |
semver: | |
name: 'Manual SemVer Tag' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Login to Quay.io | |
uses: docker/login-action@v3 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_ROBOT_USER_NAME }} | |
password: ${{ secrets.QUAY_ROBOT_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Calculate SemVer value | |
id: calculate | |
uses: UKHomeOffice/semver-calculate-action@v1 | |
with: | |
increment: ${{ github.event.inputs.increment }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
default_to_highest: ${{ github.base_ref == 'main' }} | |
- name: Calculate metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: 'quay.io/ukhomeofficedigital/hocs-info-service' | |
tags: | | |
type=raw,value=${{steps.calculate.outputs.version}} | |
type=raw,value=latest,enable=true | |
- name: Use Java 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: gradle | |
- name: Build jar | |
run: ./gradlew clean assemble --no-daemon | |
env: | |
PACKAGE_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
- name: Build container | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- name: Tag Repository | |
uses: UKHomeOffice/semver-tag-action@v3 | |
with: | |
tag: ${{ steps.calculate.outputs.version }} | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Post failure to Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
if: ${{ failure() }} | |
with: | |
channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
slack-message: "GitHub Action failure: ${{github.repository}}\nRun: ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}\nOriginating PR: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |