forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (156 loc) · 8.77 KB
/
create-deploy-tag.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
---
# - This workflow creates a tag with the format "deploy@<timestamp>" on the main branch.
# - It is triggered manually from the GitHub Actions UI.
# - It is only allowed to run on the main branch and ensures that the tag is created
# on the main branch only in a verification step.
# This is only to prevent accidental creation of the tag on other branches and cannot be used to prevent malicious creation of the tag.
name: "Serverless: Promote to QA"
on:
workflow_dispatch:
inputs:
commit:
description: "Commit to promote (default: latest commit on main)"
depth:
description: "Fetch depth (0 = everything)"
default: "500"
concurrency:
group: ${{ github.workflow }}
jobs:
create-deploy-tag:
# Temporary, we need a way to limit this to a GitHub team instead of specific users
if: contains('["watson","clintandrewhall","kobelb","lukeelmers","thomasneirynck","jbudz","mistic","delanni","Ikuni17","pheyos","dmlemeshko","mikecote"]', github.triggering_actor)
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: ${{ github.event.inputs.depth }}
fetch-tags: true
- name: Select commit to be tagged
run: |
commit="${{ github.event.inputs.commit || github.sha }}"
echo "COMMIT=${commit}" >> "${GITHUB_ENV}"
- name: Verify selected or newer commit isn't already tagged
run: |
git tag --contains ${COMMIT} | grep -P "^deploy@\d+$" && {
echo "A deploy-tag already exists on the selected or newer commit!"
exit 1
} || true
- name: Verify branch
run: |
if [[ "${GITHUB_REF}" != "refs/heads/main" ]]; then
echo "This workflow can only be run on the main branch"
exit 1
fi
- name: Find previous tag
run: |
prev_tag_name=`git tag -l 'deploy@[0-9]*' | tail -1`
echo "PREV_TAG_NAME=${prev_tag_name}" >> "${GITHUB_ENV}"
- name: Prepare tag
run: |
tag_name="deploy@$(date +%s)"
echo "TAG_NAME=${tag_name}" >> "${GITHUB_ENV}"
- name: Create tag
run: |
git tag ${TAG_NAME} ${COMMIT}
git push origin "refs/tags/${TAG_NAME}"
- name: Post Slack success message
if: success()
uses: slackapi/[email protected]
continue-on-error: true
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Promotion of a new <https://github.com/elastic/kibana/commit/${{ env.COMMIT }}|commit> to QA has been initiated!\n\nOnce promotion is complete, please begin any required manual testing.\n\n*Remember:* Promotion to Staging is currently a manual process and will proceed once the build is signed off in QA."
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Initiated by:*\n<https://github.com/${{ github.triggering_actor }}|${{ github.triggering_actor }}>"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n<https://github.com/elastic/kibana/commit/${{ env.COMMIT }}|${{ env.COMMIT }}>"
},
{
"type": "mrkdwn",
"text": "*Git tag:*\n<https://github.com/elastic/kibana/releases/tag/${{ env.TAG_NAME }}|${{ env.TAG_NAME }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ join(fromJSON(env.JSON_USEFUL_LINKS_ARRAY), '\n • ') }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEPLOY_TAGGER_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
JSON_USEFUL_LINKS_ARRAY: |
[
"*Useful links:*\\n",
"<https://github.com/elastic/kibana/compare/${{ env.PREV_TAG_NAME }}...${{ env.TAG_NAME }}|Commits contained in deploy>",
"<https://buildkite.com/elastic/kibana-serverless-release/builds?branch=${{ env.TAG_NAME }}|Kibana Serverless Release pipeline>",
"<https://argo-workflows.us-central1.gcp.qa.cld.elstc.co/workflows?label=hash%3D${{ env.COMMIT }}|Argo Workflow> (use Elastic Cloud Staging VPN)",
"<https://overview.qa.cld.elstc.co/app/dashboards#/view/serverless-tooling-gpctl-deployment-status?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&service-name=kibana&_a=(controlGroupInput:(chainingSystem:HIERARCHICAL,controlStyle:oneLine,ignoreParentSettings:(ignoreFilters:!f,ignoreQuery:!f,ignoreTimerange:!f,ignoreValidations:!f),panels:('18201b8e-3aae-4459-947d-21e007b6a3a5':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:commit-hash,id:'18201b8e-3aae-4459-947d-21e007b6a3a5',selectedOptions:!('${{ env.COMMIT }}'),title:commit-hash),grow:!t,order:1,type:optionsListControl,width:medium),'41060e65-ce4c-414e-b8cf-492ccb19245f':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:service-name,id:'41060e65-ce4c-414e-b8cf-492ccb19245f',selectedOptions:!(kibana),title:service-name),grow:!t,order:0,type:optionsListControl,width:medium),ed96828e-efe9-43ad-be3f-0e04218f79af:(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:to-env,id:ed96828e-efe9-43ad-be3f-0e04218f79af,selectedOptions:!(qa),title:to-env),grow:!t,order:2,type:optionsListControl,width:medium))))|GPCTL Deployment Status dashboard for nonprod>",
"<https://overview.elastic-cloud.com/app/dashboards#/view/serverless-tooling-gpctl-deployment-status?_g=(refreshInterval:(pause:!t,value:0),time:(from:now-1d,to:now))&service-name=kibana&_a=(controlGroupInput:(chainingSystem:HIERARCHICAL,controlStyle:oneLine,ignoreParentSettings:(ignoreFilters:!f,ignoreQuery:!f,ignoreTimerange:!f,ignoreValidations:!f),panels:('18201b8e-3aae-4459-947d-21e007b6a3a5':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:commit-hash,id:'18201b8e-3aae-4459-947d-21e007b6a3a5',selectedOptions:!('${{ env.COMMIT }}'),title:commit-hash),grow:!t,order:1,type:optionsListControl,width:medium),'41060e65-ce4c-414e-b8cf-492ccb19245f':(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:service-name,id:'41060e65-ce4c-414e-b8cf-492ccb19245f',selectedOptions:!(kibana),title:service-name),grow:!t,order:0,type:optionsListControl,width:medium),ed96828e-efe9-43ad-be3f-0e04218f79af:(explicitInput:(dataViewId:'serverless.logs-*',enhancements:(),fieldName:to-env,id:ed96828e-efe9-43ad-be3f-0e04218f79af,selectedOptions:!(production),title:to-env),grow:!t,order:2,type:optionsListControl,width:medium))))|GPCTL Deployment Status dashboard>",
"<https://buildkite.com/elastic/kibana-tests/builds?branch=main|Quality Gate pipeline>"
]
- name: Post Slack failure message
if: failure()
uses: slackapi/[email protected]
with:
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "Creation of deploy tag on <https://github.com/elastic/kibana/commit/${{ env.COMMIT }}|commit> failed ⛔️"
}
},
{
"type": "section",
"fields": [
{
"type": "mrkdwn",
"text": "*Initiated by:*\n<https://github.com/${{ github.triggering_actor }}|${{ github.triggering_actor }}>"
},
{
"type": "mrkdwn",
"text": "*Commit:*\n<https://github.com/elastic/kibana/commit/${{ env.COMMIT }}|${{ env.COMMIT }}>"
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ join(fromJSON(env.JSON_USEFUL_LINKS_ARRAY), '\n • ') }}"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.DEPLOY_TAGGER_SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
JSON_USEFUL_LINKS_ARRAY: |
[
"*Useful links:*\\n",
"<https://github.com/elastic/kibana/actions/runs/${{ github.run_id }}|GitHub Workflow run>"
]