-
Notifications
You must be signed in to change notification settings - Fork 67
120 lines (115 loc) · 3.99 KB
/
eda-update-server.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
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
name: EDA Update E2E Server
on:
workflow_dispatch:
inputs:
EDA_SERVER:
type: string
description: 'EDA Server'
UPDATE_SERVER:
type: boolean
required: true
default: false
description: 'Update server on success'
schedule:
- cron: '0 8 * * *'
jobs:
setup:
name: Setup
runs-on: ubuntu-latest
outputs:
EDA_SERVER: ${{ steps.step1.outputs.EDA_SERVER }}
UPDATE_SERVER: ${{ steps.step1.outputs.UPDATE_SERVER }}
steps:
- id: step1
run: |
CURRENTDATE=$(date +'%Y%m%d')
if([ "${{ github.event_name }}" == "workflow_dispatch" ]); then
echo "EDA_SERVER=${{ github.event.inputs.EDA_SERVER || 'https://eda.ci-ui-${CURRENTDATE}.gcp.testing.ansible.com' }}" >> "$GITHUB_OUTPUT"
echo "UPDATE_SERVER=${{ github.event.inputs.UPDATE_SERVER }}" >> "$GITHUB_OUTPUT"
else
echo "EDA_SERVER=https://eda.ci-ui-${CURRENTDATE}.gcp.testing.ansible.com" >> "$GITHUB_OUTPUT"
echo "UPDATE_SERVER=true" >> "$GITHUB_OUTPUT"
fi
eda-e2e:
name: EDA E2E
needs: setup
uses: ./.github/workflows/eda-e2e.yml
with:
EDA_SERVER: ${{ needs.setup.outputs.EDA_SERVER }}
secrets:
EDA_PASSWORD: ${{ secrets.EDA_PASSWORD }}
EDA_PROJECT_ID: ${{ secrets.EDA_PROJECT_ID }}
EDA_RECORD_KEY: ${{ secrets.EDA_RECORD_KEY }}
eda-update-server:
name: EDA Update Server
if: ${{ needs.setup.outputs.UPDATE_SERVER == 'true' }}
needs:
- eda-e2e
- setup
runs-on: ubuntu-latest
steps:
- name: Update Server Variable
run: |
curl -f -L -X PATCH -H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GH_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/actions/variables/EDA_SERVER" \
-d '{"name":"EDA_SERVER","value":"${{ needs.setup.outputs.EDA_SERVER }}"}'
- name: Slack Notification
uses: slackapi/[email protected]
with:
payload: |
{
"attachments":
[
{
"color": "#00DD00",
"blocks":
[
{
"type": "section",
"text":
{
"type": "mrkdwn",
"text": "*Ansible-UI EDA E2E Server Updated* - <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Success> - <${{ needs.setup.outputs.EDA_SERVER }}|Server>"
}
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
slack-failure-notification:
name: Slack Failure Notification
if: ${{ failure() && needs.setup.outputs.UPDATE_SERVER == 'true' }}
needs:
- eda-update-server
- setup
runs-on: ubuntu-latest
steps:
- name: Slack Notification
uses: slackapi/[email protected]
with:
payload: |
{
"attachments":
[
{
"color": "#FF0000",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Ansible-UI EDA E2E Server Update Failed* - *<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Failure>* - <${{ needs.setup.outputs.EDA_SERVER }}|Server>"
}
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK