-
Notifications
You must be signed in to change notification settings - Fork 9
60 lines (54 loc) · 2.15 KB
/
service_test2.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
on:
workflow_dispatch:
inputs:
service_test1:
description: 'service_test1'
type: boolean
required: false
default: false
service_test2:
description: 'service_test2'
type: boolean
required: false
default: false
service_test3:
description: "service_test3"
type: boolean
required: false
default: false
jobs:
build-deploy-production:
runs-on: ubuntu-latest
environment: production
if: ${{ startsWith(github.ref, 'refs/heads/master') && contains('["tainguyenbp"]', github.actor) }}
steps:
- name: Checkout
uses: actions/[email protected]
- name: Pre-check step, build & deploy service to the production environments
if: ${{ github.event.ref == 'refs/heads/master' }}
run: |
BRANCH='master'
ORG='tanguyenbp'
REPO='prometheus-grafana'
INPUT_JSON=$(echo '${{ toJson(github.event.inputs) }}')
echo "INPUT_JSON: $INPUT_JSON"
INPUT_DESC=$(echo "$INPUT_JSON" | jq -r 'keys_unsorted[]')
for ITEM in $INPUT_DESC; do
echo "ITEM is : ${ITEM}"
# Extract description and value
value=$(echo "${{ toJson(github.event.inputs) }}" | jq -r "."${ITEM}" // empty")
echo "The value of $ITEM is: $value"
GET_WORKFLOW_NAME="github.event.inputs.${ITEM}"
value=$(echo "${{ toJson(github.event) }}" | jq -r ".$GET_WORKFLOW_NAME")
echo "The value of service_test1 is: $value"
# Check if the description corresponds to a workflow in the list and its value is true
if [[ "$WORKFLOW_NAME" == "true" ]]; then
echo "Triggering workflow run for $WORKFLOW_NAME..."
# Trigger the workflow run
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: token $TOKEN" \
https://api.github.com/repos/${ORG}/${REPO}/actions/workflows/${DESC}.yml/dispatches \
--data "{\"ref\": \"$BRANCH\"}"
fi
done