Skip to content

v0.4.0

v0.4.0 #26

Workflow file for this run

name: PROD
on:
release:
types: [published]
workflow_dispatch:
inputs:
containers_tag:
description: 'The tag of the containers to deploy, if not provided, it will use the test tag'
required: false
default: 'test'
type: string
concurrency:
group: prod
cancel-in-progress: false
# This concurrency group ensures that only one workflow runs at a time for the main branch.
permissions:
id-token: write # This is required for requesting the JWT
contents: write # This is required for actions/checkout
packages: write
jobs:
vars:
name: Vars
runs-on: ubuntu-24.04
outputs:
tag: ${{ steps.release.outputs.tag }}
tags: ${{ steps.release.outputs.tags }}
clean_changelog: ${{ steps.changelog.outputs.clean_changelog || '' }}
steps:
- uses: actions/checkout@v4
- name: Conventional Changelog Update
if: (github.event_name != 'release')
uses: TriPSs/conventional-changelog-action@v6
id: changelog
continue-on-error: true
with:
github-token: ${{ github.token }}
output-file: "CHANGELOG.md"
skip-version-file: "true"
skip-on-empty: "false"
skip-commit: "true"
git-push: "true"
- name: GitHub Release
id: release
shell: bash
run: |
# Determine the tag based on the event type
tag=""
version=""
if [[ "${{ github.event_name }}" == "release" ]]; then
echo "getting tag from release which was done manually in github"
# remove all spaces and new lines from the tag name and make it lowercase.
tag=$(echo "${{ github.event.release.tag_name }}" | tr -d ' \n\r\t' | tr '[:upper:]' '[:lower:]')
version=$(echo "$tag" | sed 's/^v//') # Compute version as tag without the leading 'v'
elif [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "generating tag from workflow dispatch"
# Generate tag from current timestamp or use a default
tag=$(echo "${{ steps.changelog.outputs.tag}}" | tr -d ' \n\r\t' | tr '[:upper:]' '[:lower:]')
version="${{ steps.changelog.outputs.version}}"
else
echo "unsupported event type: ${{ github.event_name }}"
exit 1
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
# Generate multiline tags output for retag-images step
tags=$(printf "prod\n%s\n%s" "$version" "$tag")
# Trim and set multiline outputs
echo "tags<<EOF" >> $GITHUB_OUTPUT
echo "$tags" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//' >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
retag-images:
name: Retag Images
needs: [vars]
runs-on: ubuntu-24.04
strategy:
matrix:
package: [backend, frontend]
steps:
- name: retag
uses: shrink/actions-docker-registry-tag@f04afd0559f66b288586792eb150f45136a927fa # v4
with:
registry: ghcr.io
repository: ${{ github.repository }}/${{ matrix.package }}
target: ${{ inputs.containers_tag || 'test' }} # this is the tag of the containers to deploy, defaults to test
tags: |
${{ needs.vars.outputs.tags }}
resume-resources:
name: Resume Resources # This job resumes resources for the merged PR which is needed if the resources were paused.
needs: [vars]
uses: ./.github/workflows/resume-resources.yml
with:
app_env: prod
secrets: inherit
deploy:
name: Deploy Stack
needs: [vars, resume-resources, retag-images]
uses: ./.github/workflows/.deploy_stack.yml
secrets: inherit
with:
environment_name: prod
command: apply
tag: ${{ needs.vars.outputs.tag}} # this is the tag of the containers to deploy
app_env: prod
release:
name: Github Release
runs-on: ubuntu-24.04
needs: [vars, deploy]
if: (needs.vars.outputs.tag != '' && github.event_name != 'release')
steps:
- name: Create Release
uses: softprops/action-gh-release@v2
if: (needs.vars.outputs.tag != '')
continue-on-error: true
env:
GITHUB_TOKEN: ${{ github.token }}
with:
token: ${{ github.token }}
tag_name: ${{ needs.vars.outputs.tag }}
name: ${{ needs.vars.outputs.tag }}
body: ${{ needs.vars.outputs.clean_changelog }}
pause-resources:
name: Pause Resources # This job pauses resources for the merged PR which is needed if the resources were not paused, this is to save money, remove it after cloning.
needs: [release]
uses: ./.github/workflows/pause-resources.yml
with:
app_env: prod
secrets: inherit