Skip to content

Commit 827c9c6

Browse files
committed
Add automatic access to private repo on star
1 parent 1239c89 commit 827c9c6

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

.github/workflows/grant-access.yml

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
11
name: Grant Access to Private Repo
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
username:
7-
description: 'GitHub Username'
8-
required: true
4+
watch:
5+
types: [started]
96

107
jobs:
118
check_star_and_grant_access:
129
runs-on: ubuntu-latest
1310
steps:
14-
- name: Check if user has starred the repo
15-
id: check_star
16-
run: |
17-
curl -s https://api.github.com/repos/hamsadev/EmbeddedC-Tutorials-and-Challenges/stargazers | grep ${{ github.event.inputs.username }} || exit 1
18-
1911
- name: Add user to private repo
20-
if: success()
2112
run: |
2213
curl -X PUT -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
2314
-H "Accept: application/vnd.github.v3+json" \
24-
https://api.github.com/repos/hamsadev/EmbeddedC-Solutions/collaborators/${{ github.event.inputs.username }} \
15+
https://api.github.com/repos/hamsadev/EmbeddedC-Solutions/collaborators/${{ github.event.sender.login }} \
2516
-d '{"permission":"pull"}'
2617
2718
- name: Send confirmation
28-
if: success()
29-
run: echo "Access granted to private repository for user ${{ github.event.inputs.username }}."
19+
run: echo "Access granted to private repository (EmbeddedC-Solutions) for user ${{ github.event.sender.login }}."

0 commit comments

Comments
 (0)