This repository has been archived by the owner on May 3, 2024. It is now read-only.
[Release step 3 | automatic] Prepare docker tags #206
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: '[Release step 3 | automatic] Prepare docker tags' | |
on: | |
workflow_dispatch: | |
inputs: | |
tag_version: | |
description: 'Semantic Version' | |
required: true | |
docker_meta_tag: | |
type: choice | |
options: | |
- do_not_tag | |
- latest | |
- next | |
description: When manually triggering a deployment, specify which meta tag such as `latest` should be used. `do_not_tag` will result in no meta tag being applied. | |
required: true | |
push: | |
tags: | |
- '*' | |
repository_dispatch: | |
types: [release-step-3_automatic_prepare-docker-tags] | |
jobs: | |
release-step-3_automatic_prepare-docker-tags: | |
name: Docker Tag Version Check | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set env | |
id: set_tag_version | |
run: | | |
#Checks for when a valid tag is manually pushed | |
if [[ $GITHUB_REF != "" && "${{ github.event.client_payload.tagversion }}" == "" ]]; | |
then | |
echo "tagversion=$(egrep -o '^v([0-9]+\.[0-9]+\.[0-9]+)(-\S*)?' <<< $GITHUB_REF)" >> $GITHUB_OUTPUT | |
else | |
echo "tagversion=${{ github.event.client_payload.tagversion }}" >> $GITHUB_OUTPUT | |
fi | |
if [[ "${{ github.event.inputs.tag_version }}" != "" ]] | |
then | |
echo "tagversion=${{ github.event.inputs.tag_version }}" >> $GITHUB_OUTPUT | |
fi | |
echo $tagversion | |
- name: Normalize meta tag | |
id: set_docker_meta_tag | |
run: | | |
# if a meta tag was specified this was a manual build | |
if [[ "${{ github.event.inputs.docker_meta_tag }}" != "" ]] | |
then | |
echo "metatag=${{ github.event.inputs.docker_meta_tag }}" >> $GITHUB_OUTPUT | |
echo From manual run: ${{ github.event.inputs.docker_meta_tag }} | |
# if we are on the main branch, default to `latest` | |
elif [[ "$GITHUB_REF" == "refs/heads/main" ]] | |
then | |
echo "metatag=latest" >> $GITHUB_OUTPUT | |
echo For main branch: latest | |
# if we are not on the main branch, default to `do_not_tag` | |
else | |
echo "metatag=do_not_tag" >> $GITHUB_OUTPUT | |
echo For other branch: do_not_tag | |
fi | |
- name: Check Tag Version | |
run: | | |
if [[ "${{ steps.set_tag_version.outputs.tagversion }}" == "" ]]; then | |
echo "::error::Incorrect tag provided, please provide a tag with the correct format and try again" | |
exit 1 | |
fi | |
- name: Docker tag version | |
id: set_docker_tag_version | |
run: | | |
# trimmed off 'v' from tagversion | |
tagversion=${{ steps.set_tag_version.outputs.tagversion }} | |
echo "dockertag=$(sed 's/^v*//' <<< "$tagversion")" >> $GITHUB_OUTPUT | |
# ensure tag is available | |
- uses: actions/checkout@v4 | |
with: | |
ref: "v${{ steps.set_docker_tag_version.outputs.dockertag }}" | |
- name: Trigger Production Image Publishing | |
uses: octokit/[email protected] | |
id: dispatch_release-step-4_automatic_docker-prod-build-and-publish | |
with: | |
route: POST /repos/:repository/dispatches | |
repository: ${{ github.repository }} | |
mediaType: '{"previews": ["everest"]}' | |
event_type: "release-step-4_automatic_docker-prod-build-and-publish" | |
client_payload: '{"docker_tag_version": "${{ steps.set_docker_tag_version.outputs.dockertag }}", "docker_meta_tag": "${{ steps.set_docker_meta_tag.outputs.metatag }}"}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.PA_TOKEN }} |