Skip to content

Commit b8ffb9c

Browse files
authored
Merge pull request #15328 from rancher/valid-pr-change
Add workflow to notify slack of milestone changes made by those external to team
2 parents 085a115 + 4fdbc5c commit b8ffb9c

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Check for Unexpected Milestone Change
2+
3+
on:
4+
issues:
5+
types: [milestoned, demilestoned, edited]
6+
7+
permissions:
8+
issues: read
9+
10+
jobs:
11+
notify-on-milestone-change:
12+
if: |
13+
github.event.action == 'milestoned' ||
14+
github.event.action == 'demilestoned' ||
15+
(github.event.action == 'edited' && github.event.changes.milestone)
16+
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Set Event Data
20+
id: event_data
21+
run: |
22+
if [ "${{ github.event.action }}" == "milestoned" ]; then
23+
echo "OLD_MILESTONE=None"
24+
echo "NEW_MILESTONE=${{ github.event.issue.milestone.title }}"
25+
26+
elif [ "${{ github.event.action }}" == "demilestoned" ]; then
27+
echo "OLD_MILESTONE=${{ github.event.milestone.title }}"
28+
echo "NEW_MILESTONE=None"
29+
30+
elif [ "${{ github.event.action }}" == "edited" ]; then
31+
echo "OLD_MILESTONE=${{ github.event.changes.milestone.from.title || 'None' }}"
32+
echo "NEW_MILESTONE=${{ github.event.issue.milestone.title || 'None' }}"
33+
fi >> $GITHUB_ENV
34+
35+
echo "ACTOR=${{ github.event.sender.login }}" >> $GITHUB_ENV
36+
echo "ISSUE_TITLE=${{ github.event.issue.title }}" >> $GITHUB_ENV
37+
echo "ISSUE_URL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV
38+
- name: Check Team Membership
39+
id: check_team
40+
continue-on-error: true
41+
env:
42+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43+
run: |
44+
gh api --silent \
45+
/orgs/rancher/teams/ui/memberships/${{ github.event.sender.login }}
46+
- name: "Send Slack message if user is not a team member"
47+
if: steps.check_team.outcome == 'failure'
48+
uses: slackapi/[email protected]
49+
with:
50+
payload: |
51+
{
52+
"actor": "${{ env.ACTOR }}",
53+
"issue_title": "${{ env.ISSUE_TITLE }}",
54+
"issue_url": "${{ env.ISSUE_URL }}",
55+
"milestone_new": "${{ env.NEW_MILESTONE }}",
56+
"milestone_old": "${{ env.OLD_MILESTONE }}"
57+
}
58+
env:
59+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WORKFLOW_MILESTONE_CHANGED_URL }}

0 commit comments

Comments
 (0)