-
Notifications
You must be signed in to change notification settings - Fork 9
160 lines (149 loc) · 5.19 KB
/
on-board.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
name: on-board
on:
issues:
types:
- labeled
jobs:
link_to_issue:
if: github.event.label.name == 'processing'
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
})
parse_info:
needs: link_to_issue
runs-on: ubuntu-latest
outputs:
github_handle: ${{ steps.main.outputs.github_handle }}
discord_handle: ${{ steps.main.outputs.discord_handle }}
team_slug: ${{ steps.main.outputs.team_slug }}
previous_team_slug: ${{ steps.main.outputs.previous_team_slug }}
privilege: ${{ steps.main.outputs.privilege }}
repository: ${{ steps.main.outputs.repository }}
steps:
- uses: actions/checkout@v3
- id: main
shell: bash
run: |
set -e
source .github/scripts/parse-issue-title.sh "${{ github.event.issue.title }}"
source .github/scripts/parse-issue-body.sh "${{ github.event.issue.body }}"
source .github/scripts/get-team-slug.sh "$PRIVILEGE" "$REPOSITORY"
echo "github_handle=$GITHUB_HANDLE" >> $GITHUB_OUTPUT
echo "discord_handle=$DISCORD_HANDLE" >> $GITHUB_OUTPUT
echo "team_slug=$TEAM_SLUG" >> $GITHUB_OUTPUT
echo "previous_team_slug=$PREVIOUS_TEAM_SLUG" >> $GITHUB_OUTPUT
echo "privilege=$PRIVILEGE" >> $GITHUB_OUTPUT
echo "repository=$REPOSITORY" >> $GITHUB_OUTPUT
case $TEAM_SLUG in
*monorepo*)
maintainers=(
"mvines"
"CriesofCarrots"
"joeaba"
"t-nelson"
"sakridge"
"yihau"
)
if [[ ! " ${maintainers[*]} " =~ " ${{github.event.sender.login}} " ]]; then
echo "isn't a maintainer in monorepo"
exit 1
fi
;;
*spl*)
maintainers=(
"mvines"
"CriesofCarrots"
"joeaba"
"t-nelson"
"sakridge"
"yihau"
"joncinque"
)
if [[ ! " ${maintainers[*]} " =~ " ${{github.event.sender.login}} " ]]; then
echo "isn't a maintainer in spl"
exit 1
fi
;;
*)
echo "unexpected team slug: $TEAM_SLUG"
exit 1
;;
esac
add_to_github_group:
needs: [parse_info]
uses: ./.github/workflows/add-to-github-group.yml
with:
team_slug: ${{ needs.parse_info.outputs.team_slug }}
previous_team_slug: ${{ needs.parse_info.outputs.previous_team_slug }}
github_handle: ${{ needs.parse_info.outputs.github_handle }}
secrets:
PAT: ${{ secrets.PAT }}
add_discord_role:
needs: [parse_info]
uses: ./.github/workflows/add-discord-role.yml
with:
team_slug: ${{ needs.parse_info.outputs.team_slug }}
discord_handle: ${{ needs.parse_info.outputs.discord_handle }}
secrets:
PAT: ${{ secrets.PAT }}
DISCORD_DEVBOT_TOKEN: ${{ secrets.DISCORD_DEVBOT_TOKEN }}
DISCORD_SOLANA_GUILD_ID: ${{ secrets.DISCORD_SOLANA_GUILD_ID }}
update_acl:
needs: [parse_info]
uses: ./.github/workflows/update-acl.yml
with:
github_handle: ${{ needs.parse_info.outputs.github_handle }}
discord_handle: ${{ needs.parse_info.outputs.discord_handle }}
repository: ${{ needs.parse_info.outputs.repository }}
privilege: ${{ needs.parse_info.outputs.privilege }}
secrets:
PAT: ${{ secrets.PAT }}
on_success:
needs: [add_to_github_group, add_discord_role, update_acl]
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.PAT }}
script: |
github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ["approved"]
})
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: "${{ github.event.label.name }}"
})
github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
state: 'closed',
state_reasonstring: 'completed'
})
on_failure:
needs: [add_to_github_group, add_discord_role, update_acl]
if: ${{ failure() }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: "${{ github.event.label.name }}"
})