Skip to content

Grant Access to Private Repo #3

Grant Access to Private Repo

Grant Access to Private Repo #3

Workflow file for this run

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 }}."