-
Notifications
You must be signed in to change notification settings - Fork 486
113 lines (109 loc) · 4.61 KB
/
RELEASE_ISSUE.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
name: RELEASE_ISSUE
on:
issues:
types: [closed, assigned]
jobs:
create_release_issue:
runs-on: ubuntu-latest
name: Create new Release Issue
if: |
contains(github.event.issue.labels.*.name, 'release') &&
github.event.action == 'closed'
outputs:
assignee: ${{ steps.create_release_issue.outputs.assignee }}
issue: ${{ steps.create_release_issue.outputs.issue }}
steps:
- id: create_release_issue
name: Create new Release Issue
uses: bpmn-io/actions/release-issue@latest
with:
template-path: 'docs/.project/RELEASE_TEMPLATE.md'
package-path: 'app/package.json'
assign_milestone:
name: Assign milestone
needs: create_release_issue
if: github.event.issue.milestone
runs-on: ubuntu-latest
steps:
- name: Get current Milestone
id: getMilestone
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch the list of milestones for the repository
# Filter for milestones that start with 'M' and are open
MILESTONE=$(gh api -H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/milestones \
--jq '.[] | select(.title | startswith("M")) | .number'
)
echo "MILESTONE_NUMBER=$MILESTONE" >> $GITHUB_OUTPUT
- name: Assign Milestone to new Issue
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ fromJson(needs.create_release_issue.outputs.issue).number }} \
-F "milestone=${{steps.getMilestone.outputs.MILESTONE_NUMBER}}"
update_slack_role:
name: Sync Slack roles
needs: create_release_issue
runs-on: ubuntu-latest
if: |
always() &&
contains(github.event.issue.labels.*.name, 'release')
steps:
- name: Import Secrets
id: secrets
uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
exportEnv: false
secrets: |
secret/data/products/desktop-modeler/ci/slack_integration RELEASE_MANAGER_GROUP_ID;
secret/data/products/desktop-modeler/ci/slack_integration SLACK_BOT_TOKEN;
secret/data/products/desktop-modeler/ci/slack_integration TEAM_MEMBER_IDS;
- name: Update slack
env:
SLACK_BOT_TOKEN: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}
GROUP_ID: ${{ steps.secrets.outputs.RELEASE_MANAGER_GROUP_ID }}
# User ID is either the assignee from the newly created issue or the new assigned from the `assigned` trigger
USER_ID: ${{ fromJSON(steps.secrets.outputs.TEAM_MEMBER_IDS)[ needs.create_release_issue.outputs.assignee || github.event.issue.assignee.login ] }}
run: |
curl --fail-with-body -X POST -H "application/x-www-form-urlencoded" -d "token=${SLACK_BOT_TOKEN}&usergroup=${GROUP_ID}&users=${USER_ID}" https://slack.com/api/usergroups.users.update
notify_on_slack:
name: Notify new release manager on Slack
needs: create_release_issue
if: |
always() &&
contains(github.event.issue.labels.*.name, 'release')
runs-on: ubuntu-latest
steps:
- name: Import Secrets
id: secrets
uses: hashicorp/[email protected]
with:
url: ${{ secrets.VAULT_ADDR }}
method: approle
roleId: ${{ secrets.VAULT_ROLE_ID }}
secretId: ${{ secrets.VAULT_SECRET_ID }}
exportEnv: false
secrets: |
secret/data/products/desktop-modeler/ci/slack_integration SLACK_CHANNEL_ID;
secret/data/products/desktop-modeler/ci/slack_integration SLACK_BOT_TOKEN;
- name: Post to a Slack channel
uses: slackapi/slack-github-action@v2
with:
method: chat.postMessage
token: ${{ steps.secrets.outputs.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ steps.secrets.outputs.SLACK_CHANNEL_ID }}
text: "Assigned <https://github.com/${{ env.RELEASE_MANAGER }}|@${{ env.RELEASE_MANAGER }}> as the release manager. Go to <${{ env.ISSUE_LINK }}|the release issue> to update if necessary."
env:
# Release manager is either the assignee from the newly created issue or the new assigned from the `assigned` trigger
RELEASE_MANAGER: ${{ needs.create_release_issue.outputs.assignee || github.event.issue.assignee.login }}
ISSUE_LINK: https://github.com/${{ github.repository }}/issues/${{ fromJson(needs.create_release_issue.outputs.issue).number }}