Skip to content

Commit 1239c89

Browse files
committed
Add grant access
1 parent e819cbd commit 1239c89

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

.github/workflows/grant-access.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Grant Access to Private Repo
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
username:
7+
description: 'GitHub Username'
8+
required: true
9+
10+
jobs:
11+
check_star_and_grant_access:
12+
runs-on: ubuntu-latest
13+
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+
19+
- name: Add user to private repo
20+
if: success()
21+
run: |
22+
curl -X PUT -H "Authorization: token ${{ secrets.GH_TOKEN }}" \
23+
-H "Accept: application/vnd.github.v3+json" \
24+
https://api.github.com/repos/hamsadev/EmbeddedC-Solutions/collaborators/${{ github.event.inputs.username }} \
25+
-d '{"permission":"pull"}'
26+
27+
- name: Send confirmation
28+
if: success()
29+
run: echo "Access granted to private repository for user ${{ github.event.inputs.username }}."

0 commit comments

Comments
 (0)