Grant Access to Private Repo #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Grant Access to Private Repo | |
on: | |
workflow_dispatch: | |
inputs: | |
username: | |
description: 'GitHub Username' | |
required: true | |
jobs: | |
check_star_and_grant_access: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if user has starred the repo | |
id: check_star | |
run: | | |
curl -s https://api.github.com/repos/hamsadev/EmbeddedC-Tutorials-and-Challenges/stargazers | grep ${{ github.event.inputs.username }} || exit 1 | |
- name: Add user to private repo | |
if: success() | |
run: | | |
curl -X PUT -H "Authorization: token ${{ secrets.GH_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/hamsadev/EmbeddedC-Solutions/collaborators/${{ github.event.inputs.username }} \ | |
-d '{"permission":"pull"}' | |
- name: Send confirmation | |
if: success() | |
run: echo "Access granted to private repository for user ${{ github.event.inputs.username }}." |