-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (112 loc) · 4.25 KB
/
check-lambda-context.yml
File metadata and controls
123 lines (112 loc) · 4.25 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: ♻️ Check lambda context (git...)
on:
workflow_call:
inputs:
AWS_DEFAULT_REGION:
required: true
type: string
ENVIRONMENT:
required: true
type: string
LAMBDA_NAMESPACE:
required: true
type: string
LAMBDAS:
required: true
type: string
IS_LEGACY:
description: "Indicates if target infra is legacy EC2 (DEVELOPMENT/NOTPROD/PROD envs)"
required: false
type: string
default: 'false'
SHA_SHORT:
description: "Git commit SHA short (without 'sha-' prefix)"
required: false
type: string
default: ''
NOTIFICATIONS_TEAMS: # booleans must be treated as string
required: false
type: string
default: 'true'
secrets:
AWS_ACCESS_KEY_ID_TF:
required: true
AWS_SECRET_ACCESS_KEY_TF:
required: true
MS_TEAMS_WEBHOOK_URI:
required: true
# Map the workflow outputs to job outputs
outputs:
SHA_SHORT:
description: "Define SHA_SHORT from input or current git commit SHA"
value: ${{ jobs.check-context.outputs.SHA_SHORT }}
ENVIRONMENT:
description: "Cluster name to deploy onto (sandbox, test, release, prod)"
value: ${{ jobs.check-context.outputs.ENVIRONMENT }}
JIRA_CODE:
description: "JIRA ticket code found in branch name"
value: ${{ jobs.check-context.outputs.JIRA_CODE }}
jobs:
check-context:
name: Check context
runs-on: ubuntu-22.04
timeout-minutes: 5
steps:
- uses: actions/checkout@v3
if: inputs.SHA_SHORT == ''
# Get commit SHA before checking out reusable workflows
- name: Git output SHA short
id: git-sha
if: always()
run: |
if [ "${{ inputs.SHA_SHORT }}" != "" ]; then
SHA_SHORT=${{ inputs.SHA_SHORT }}
else
SHA_SHORT=$(git rev-parse --short HEAD)
fi
if [ -z ${SHA_SHORT} ]; then
echo "::error title=Check GIT SHA::GIT SHA can not be empty"
exit 1
fi
echo "::notice title=Check GIT SHA::GIT SHA output value is '${SHA_SHORT}'"
echo "SHA_SHORT=${SHA_SHORT}" >> ${GITHUB_OUTPUT}
# Get commit message before checking out reusable workflows
- name: Git output commit message
id: git-commit
if: always()
run: |
COMMIT_MESSAGE=$(git log -1 --pretty=format:"%s")
echo "COMMIT_MESSAGE=${COMMIT_MESSAGE}" >> ${GITHUB_OUTPUT}
# Checkout reusable workflow to get bash scripts
- uses: actions/checkout@v3
with:
repository: Sonergia/github-reusable-workflows
ref: '2.x'
# ref: 'delivery' # Only when testing ############## /!\ ##############
- name: Set context from git and inputs
id: set-context
uses: sonergia/github-reusable-workflows/.github/actions/set-context@2.x
with:
ENVIRONMENT: "${{ inputs.ENVIRONMENT }}"
IS_LAMBDA: "TRUE"
IS_LEGACY: "${{ inputs.IS_LEGACY }}"
# Notify at the start of workflow
- name: Notify teams channel
if: always() && inputs.NOTIFICATIONS_TEAMS == 'true'
uses: sonergia/github-reusable-workflows/.github/actions/ms-teams-notification@2.x
continue-on-error: true
with:
MS_TEAMS_WEBHOOK_URI: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
ENVIRONMENT: ${{ steps.set-context.outputs.CLUSTER }}
SUMMARY: Déploiement lambda(s) ${{ join(fromJson(inputs.LAMBDAS), ',') }} -> ${{ steps.set-context.outputs.ENVIRONMENT }} en cours...
COLOR: 999999
COMMIT_MESSAGE: ${{ steps.git-commit.outputs.COMMIT_MESSAGE }}
JIRA_CODE: ${{ steps.set-context.outputs.JIRA_CODE }}
FACT_STATUS: ⏱ in progress...
FACT_TYPE_NAME: Lambda(s)
FACT_TYPE_VALUE: ${{ join(fromJson(inputs.LAMBDAS), ',') }}
# ACTION_AWS_URL: "https://${{ inputs.AWS_DEFAULT_REGION }}.console.aws.amazon.com/lambda/home?region=${{ inputs.AWS_DEFAULT_REGION }}#/functions"
outputs:
SHA_SHORT: ${{ steps.git-sha.outputs.SHA_SHORT }}
ENVIRONMENT: ${{ steps.set-context.outputs.ENVIRONMENT }}
JIRA_CODE: ${{ steps.set-context.outputs.JIRA_CODE }}