Skip to content

Commit c9544af

Browse files
committed
Add /invite to invite people to the private e2e repo
1 parent 06155f4 commit c9544af

File tree

2 files changed

+59
-5
lines changed

2 files changed

+59
-5
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Post link to private end-to-end test repository
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
jobs:
8+
invite:
9+
name: Invite everyone to the e2e private repo
10+
if: |
11+
github.event.issue.pull_request
12+
&& contains(github.event.comment.body, '/invite')
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
collaborator:
17+
- LOGIN: kieferro
18+
PERMISSION: admin
19+
ENABLED: "true"
20+
21+
- LOGIN: ewjoachim
22+
PERMISSION: admin
23+
ENABLED: "true"
24+
25+
- LOGIN: ${{ github.event.issue.user.login }}
26+
PERMISSION: push
27+
ENABLED: ${{ !contains(fromJson('["kieferro", "ewjoachim"]'), github.event.issue.user.login) }}
28+
29+
steps:
30+
31+
- name: Invite @${{ matrix.collaborator.LOGIN }} to the e2e private repo
32+
run: gh api --method PUT /repos/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private/collaborators/${LOGIN} -f permission=${PERMISSION}
33+
if: ${{ matrix.collaborator.ENABLED == 'true' }}
34+
env:
35+
LOGIN: ${{ matrix.collaborator.LOGIN }}
36+
NUMBER: ${{ github.event.issue.number }}
37+
PERMISSION: ${{ matrix.collaborator.PERMISSION }}
38+
GITHUB_TOKEN: ${{ secrets.COVERAGE_COMMENT_E2E_GITHUB_TOKEN_USER_1 }}
39+
40+
comment:
41+
name: Add comment with link to e2e repos
42+
if: |
43+
github.event.issue.pull_request
44+
&& contains(github.event.comment.body, '/invite')
45+
runs-on: ubuntu-latest
46+
permissions:
47+
pull-requests: write
48+
steps:
49+
- run: |
50+
gh pr comment ${LINK} --body-file - <<EOF
51+
[End-to-end private repo](https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private)
52+
In addition to repo admin, @${LOGIN} has been added to the private e2e repo
53+
EOF
54+
env:
55+
LINK: ${{ github.event.issue.html_url }}
56+
NUMBER: ${{ github.event.issue.number }}
57+
LOGIN: ${{ github.event.issue.user.login }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Post links to end-to-end test repositories
1+
name: Post link to public end-to-end test repository
22

33
on:
44
pull_request_target:
@@ -7,19 +7,15 @@ on:
77

88
jobs:
99
test:
10-
name: Publish coverage comment
1110
runs-on: ubuntu-latest
1211
permissions:
1312
pull-requests: write
1413
steps:
1514
- run: |
1615
gh pr comment ${LINK} --body-file - <<EOF
1716
[End-to-end public repo](https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-public)
18-
[End-to-end private repo](https://github.com/mihcaojwe/python-coverage-comment-action-end-to-end-${NUMBER}-private)
19-
If the tests fail, @${AUTHOR} will be added to the private repo
2017
EOF
2118
env:
2219
LINK: ${{ github.event.pull_request.html_url }}
2320
NUMBER: ${{ github.event.pull_request.number }}
24-
AUTHOR: ${{ github.event.pull_request.user.login }}
2521
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)