-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (81 loc) · 3.42 KB
/
manual.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
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}}
url: ${{ steps.deploy.outputs.deploy-url }}
concurrency: ${{github.event.inputs.environment}}
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v4
- 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 "image_tag_sha=sha-$(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_v2
id: deploy
with:
environment: "${{github.event.inputs.environment}}"
sha: "${{ steps.vars.outputs.image_tag_sha }}"
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}
- name: Slack Release Notification
if: steps.tag_id.outputs.release_id && github.event.inputs.environment == 'production_aks'
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}}