-
Notifications
You must be signed in to change notification settings - Fork 3
52 lines (44 loc) · 1.96 KB
/
review-app.yml
File metadata and controls
52 lines (44 loc) · 1.96 KB
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
name: Deploy Review App
on:
pull_request:
types: [labeled, unlabeled, closed]
jobs:
manage-review-app:
runs-on: ubuntu-latest
if: |
(github.event.action == 'labeled' && github.event.label.name == 'review-app') ||
(github.event.action == 'unlabeled' && github.event.label.name == 'review-app') ||
(github.event.action == 'closed' && contains(github.event.pull_request.labels.*.name, 'review-app'))
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Check if user is a contributor
if: github.event.action == 'labeled' && github.event.label.name == 'review-app'
uses: actions/github-script@v7
with:
script: |
try {
const labelCreator = context.actor;
console.log(`Label creator: ${labelCreator}`);
const { data: permission } = await github.rest.repos.getCollaboratorPermissionLevel({
owner: context.repo.owner,
repo: context.repo.repo,
username: labelCreator
});
console.log(`Permission level: ${permission.permission}`);
const validPermissions = ['write', 'admin', 'maintain'];
const isContributor = validPermissions.includes(permission.permission);
if (!isContributor) {
core.setFailed(`User ${labelCreator} does not have contributor access`);
}
} catch (error) {
core.setFailed(`Failed to check contributor status: ${error.message}`);
}
- name: Manage Heroku Review App
uses: fastruby/manage-heroku-review-app@v1.3
with:
action: ${{ (github.event.action == 'labeled' && github.event.label.name == 'review-app' && 'create') || 'destroy' }}
env:
HEROKU_API_TOKEN: ${{ secrets.HEROKU_API_TOKEN }}
HEROKU_PIPELINE_ID: ${{ secrets.HEROKU_PIPELINE_ID }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}