Invitation #12
This file contains 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: Invitation | |
on: | |
issues: | |
types: [labeled] | |
jobs: | |
automate_invite: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check GitHub CLI version | |
run: gh --version | |
- name: Extract batch year from issue | |
id: extract_batch_year | |
run: | | |
# Extract the batch year from the registration number | |
# Assuming the registration number starts with the batch year (e.g., 2022XXXX) | |
batch_year=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json body --jq '.body' | grep -oE '20[1-2][0-9]') | |
if [[ "$batch_year" -ge 2018 && "$batch_year" -le 2025 ]]; then | |
echo "Batch year is valid: $batch_year" | |
echo "::set-output name=batch_year::$batch_year" | |
else | |
echo "Invalid batch year: $batch_year" | |
exit 1 | |
fi | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Invite to GitHub organization | |
uses: vj-abigo/invite-on-label@v1.2 | |
with: | |
organization: LPU-Org | |
label: invite me to LPU Org | |
repo-token: ${{ secrets.REPO_TOKEN }} | |
env: | |
INVITE_TOKEN: ${{ secrets.INV_TOKEN }} | |
# - name: Post invitation comment as bot | |
# run: | | |
# gh issue comment ${{ github.event.issue.number }} --body "<b>Invitation sent to join the GitHub Organization. Welcome to the community 🎉</b><br><br>Don't forget after accepting to make it public so it appears on your GitHub profile for everyone else to see. You can do this by finding your name in the GitHub organisation list and changing the dropdown to public https://github.com/orgs/LPU-Org/people" | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Post invitation comment as bot | |
run: | | |
gh issue comment 15 --repo LPU-Org/.github --body "<b>Invitation sent to join the GitHub Organization. Welcome to the community 🎉</b><br><br>Don't forget after accepting to make it public so it appears on your GitHub profile for everyone else to see. You can do this by finding your name in the GitHub organisation list and changing the dropdown to public https://github.com/orgs/LPU-Org/people" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Add user to batch team | |
run: | | |
# Map the batch year to the corresponding team | |
team_name="Batch-${{ steps.extract_batch_year.outputs.batch_year }}" | |
# Use the GitHub API to add the user to the team | |
user_login=$(gh issue view ${{ github.event.issue.number }} --repo ${{ github.repository }} --json author --jq '.author.login') | |
gh api orgs/LPU-Org/teams/$team_name/memberships/$user_login --method PUT --input '{"role":"member"}' --header "authorization: token ${{ secrets.GITHUB_TOKEN }}" | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |