Skip to content

Manual Release

Manual Release #353

Workflow file for this run

---
name: Manual Release
on:
workflow_dispatch:
inputs:
environment:
description: Environment to release to
required: true
type: environment
tag:
description: Release Tag
required: true
jobs:
manual:
name: Deploy to ${{github.event.inputs.environment}}
runs-on: ubuntu-latest
environment:
name: ${{github.event.inputs.environment}}
concurrency: ${{github.event.inputs.environment}}
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: set-up-environment
uses: DFE-Digital/github-actions/set-up-environment@master
- uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Fetch secrets from key vault
uses: azure/CLI@v1
id: fetch-secrets
with:
inlineScript: |
SECRET_VALUE=$(az keyvault secret show --name "SLACK-WEBHOOK" --vault-name "${{ secrets.INFRA_KEY_VAULT}}" --query "value" -o tsv)
echo "::add-mask::$SECRET_VALUE"
echo "SLACK-WEBHOOK=$SECRET_VALUE" >> $GITHUB_OUTPUT
SECRET_VALUE=$(az keyvault secret show --name "SLACK-RELEASE-NOTE-WEBHOOK" --vault-name "${{ secrets.INFRA_KEY_VAULT}}" --query "value" -o tsv)
echo "::add-mask::$SECRET_VALUE"
echo "SLACK-RELEASE-NOTE-WEBHOOK=$SECRET_VALUE" >> $GITHUB_OUTPUT
- name: Get Release Id from Tag
id: tag_id
uses: DFE-Digital/github-actions/DraftReleaseByTag@master
with:
TAG: ${{ github.event.inputs.tag }}
TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Check if found
if: steps.tag_id.outputs.release_id == ''
run: |
echo "::error ::Tag ${{ github.event.inputs.tag }} cannot be found in releases"
exit 1
- name: Get Short SHA
id: vars
run: |
echo "sha_short=$(echo ${{steps.tag_id.outputs.release_sha}} | cut -c -7)" >> $GITHUB_OUTPUT
# - name: Trigger Deployment to ${{github.event.inputs.environment}}
# uses: ./.github/workflows/actions/deploy
# id: deploy
# with:
# environment: "${{github.event.inputs.environment}}"
# sha: "${{steps.tag_id.outputs.release_sha}}"
# AZURE_CREDENTIALS: ${{ secrets.AZURE_CREDENTIALS }}
# KEY_VAULT: ${{ secrets.KEY_VAULT }}
# ARM_ACCESS_KEY: ${{ secrets.ARM_ACCESS_KEY }}
- name: Trigger Deployment to ${{github.event.inputs.environment}}
uses: ./.github/workflows/actions/deploy_v2
id: deploy
with:
environment: "${{github.event.inputs.environment}}"
sha: "${{ steps.vars.outputs.sha_short }}"
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
- name: Slack Release Notification
if: steps.tag_id.outputs.release_id && github.event.inputs.environment == 'Production'
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: ${{env.SLACK_SUCCESS}}
SLACK_TITLE: "Release Published to ${{github.event.inputs.environment}}: ${{steps.tag_id.outputs.release_name}}"
SLACK_MESSAGE: ${{ fromJson( steps.tag_id.outputs.release_body) }}
SLACK_WEBHOOK: ${{steps.keyvault-yaml-secret.outputs.SLACK-RELEASE-NOTE-WEBHOOK}}
MSG_MINIMAL: true
- name: Slack Notification
if: failure()
uses: rtCamp/action-slack-notify@master
env:
SLACK_COLOR: ${{env.SLACK_FAILURE}}
SLACK_TITLE: "Manual Release Failed: ${{steps.tag_id.outputs.release_name}}"
SLACK_MESSAGE: Failure deploying ${{github.event.inputs.environment}} release
SLACK_WEBHOOK: ${{steps.keyvault-yaml-secret.outputs.SLACK-WEBHOOK}}