Skip to content

CI/CD promote

CI/CD promote #103

Workflow file for this run

name: "CI/CD promote"
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to promote to'
type: environment
required: true
env:
AWS_REGION: eu-west-2
AWS_S3_SOURCE_RELEASES_BUCKET: vita-${{ secrets.PROMOTE_SOURCE_AWS_ACCOUNT_ID }}-releases-${{ vars.PROMOTE_SOURCE_ENVIRONMENT }}
AWS_S3_TARGET_RELEASES_BUCKET: vita-${{ secrets.AWS_ACCOUNT_ID }}-releases-${{ github.event.inputs.environment }}
jobs:
#################################################
# Set up metadata for the jobs
#################################################
metadata:
name: "Set CI/CD metadata"
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
build_datetime: ${{ steps.variables.outputs.build_datetime }}
build_timestamp: ${{ steps.variables.outputs.build_timestamp }}
build_epoch: ${{ steps.variables.outputs.build_epoch }}
version: ${{ steps.variables.outputs.version }}
release_tag: ${{ steps.variables.outputs.release_tag }}
steps:
- name: "Check is ${{ github.ref }} a tag"
run: |
if ${{ !startsWith(github.ref, 'refs/tags/') }}; then
echo "❌ Only tagged promotions allowed."
exit 1
fi
- name: "Checkout code"
uses: actions/checkout@v6
- name: "Set CI/CD variables"
id: variables
run: |
datetime=$(date -u +'%Y-%m-%dT%H:%M:%S%z')
echo "build_datetime=$datetime" >> $GITHUB_OUTPUT
echo "build_timestamp=$(date --date=$datetime -u +'%Y%m%d%H%M%S')" >> $GITHUB_OUTPUT
echo "build_epoch=$(date --date=$datetime -u +'%s')" >> $GITHUB_OUTPUT
# TODO: Get the version, but it may not be the .version file as this should come from the CI/CD Pull Request Workflow
echo "version=$(head -n 1 .version 2> /dev/null || echo unknown)" >> $GITHUB_OUTPUT
echo "release_tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- name: "List variables"
run: |
export BUILD_DATETIME="${{ steps.variables.outputs.build_datetime }}"
export BUILD_TIMESTAMP="${{ steps.variables.outputs.build_timestamp }}"
export BUILD_EPOCH="${{ steps.variables.outputs.build_epoch }}"
export VERSION="${{ steps.variables.outputs.version }}"
export RELEASE_TAG="${{ steps.variables.outputs.release_tag }}"
make list-variables
#################################################################
# Promote stage - promote builds from one environment to another
#################################################################
promote-stage:
name: "Promote stage"
needs: [ metadata ]
uses: ./.github/workflows/stage-6-promote.yaml
with:
environment: ${{ inputs.environment }}
release_tag: ${{ github.ref_name }}
secrets: inherit