-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add-member workflow to trigger on issue-open
- Loading branch information
Showing
1 changed file
with
20 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,11 @@ | ||
name: "Add new member to django-commons" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
username: | ||
description: "Username of the new member" | ||
required: true | ||
default: "new_member" | ||
issue_number: | ||
description: "Issue number to reference in the PR body" | ||
required: false | ||
default: "0" | ||
issues: | ||
types: | ||
- opened | ||
labels: | ||
- "New member" | ||
|
||
jobs: | ||
add-member: | ||
|
@@ -20,6 +15,9 @@ jobs: | |
id-token: write | ||
contents: write | ||
pull-requests: write | ||
env: | ||
ISSUE_ID: ${{ github.event.issue.id }} | ||
BRANCH_NAME: "add-user/${{ env.ISSUE_ID }}" | ||
|
||
steps: | ||
- name: Setup python | ||
|
@@ -30,30 +28,35 @@ jobs: | |
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get username to add | ||
id: get_username | ||
run: | ||
python -c "print('USERNAME='+'✋ [MEMBER] - <your handle>'.split(' - ')[1])" >> $GITHUB_ENV | ||
|
||
- name: Initialize mandatory git config | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email [email protected] | ||
- name: Create branch | ||
run: git checkout -b add-user/${{ inputs.username }} | ||
run: git checkout -b ${{ env.BRANCH_NAME }} | ||
|
||
- name: Add user to the list | ||
run: | | ||
python scripts/add_member.py ${{ inputs.username }} | ||
python scripts/add_member.py ${{ env.USERNAME }} | ||
- name: Commit changes | ||
run: | | ||
git add terraform/production/org.tfvars | ||
git commit -m "Add ${{ inputs.username }} to django-commons" | ||
git push origin add-user/${{ inputs.username }} | ||
git commit -m "Add ${{ env.USERNAME }} to django-commons" | ||
git push origin ${{ env.BRANCH_NAME }} | ||
- name: Create pull request | ||
run: | | ||
gh pr create \ | ||
--title "Add ${{ inputs.username }} to django-commons" \ | ||
--body "Fix #${{ inputs.issue_number }}" \ | ||
--title "Add ${{ env.USERNAME }} to django-commons" \ | ||
--body "Fix #${{ env.ISSUE_ID }}" \ | ||
--base main \ | ||
--head add-user/${{ inputs.username }} | ||
--head ${{ env.BRANCH_NAME }} | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |