Skip to content

Commit f243804

Browse files
committed
add-member workflow to trigger on issue-open
1 parent 99da31c commit f243804

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

.github/workflows/add_member.yml

+20-17
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
name: "Add new member to django-commons"
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
username:
7-
description: "Username of the new member"
8-
required: true
9-
default: "new_member"
10-
issue_number:
11-
description: "Issue number to reference in the PR body"
12-
required: false
13-
default: "0"
4+
issues:
5+
types:
6+
- opened
7+
labels:
8+
- "New member"
149

1510
jobs:
1611
add-member:
@@ -20,6 +15,9 @@ jobs:
2015
id-token: write
2116
contents: write
2217
pull-requests: write
18+
env:
19+
ISSUE_ID: ${{ github.event.issue.id }}
20+
BRANCH_NAME: "add-user/${{ env.ISSUE_ID }}"
2321

2422
steps:
2523
- name: Setup python
@@ -30,30 +28,35 @@ jobs:
3028
- name: Checkout code
3129
uses: actions/checkout@v4
3230

31+
- name: Get username to add
32+
id: get_username
33+
run:
34+
python -c "print('USERNAME='+'✋ [MEMBER] - <your handle>'.split(' - ')[1])" >> $GITHUB_ENV
35+
3336
- name: Initialize mandatory git config
3437
run: |
3538
git config user.name "GitHub Actions"
3639
git config user.email [email protected]
3740
3841
- name: Create branch
39-
run: git checkout -b add-user/${{ inputs.username }}
42+
run: git checkout -b ${{ env.BRANCH_NAME }}
4043

4144
- name: Add user to the list
4245
run: |
43-
python scripts/add_member.py ${{ inputs.username }}
46+
python scripts/add_member.py ${{ env.USERNAME }}
4447
4548
- name: Commit changes
4649
run: |
4750
git add terraform/production/org.tfvars
48-
git commit -m "Add ${{ inputs.username }} to django-commons"
49-
git push origin add-user/${{ inputs.username }}
51+
git commit -m "Add ${{ env.USERNAME }} to django-commons"
52+
git push origin ${{ env.BRANCH_NAME }}
5053
5154
- name: Create pull request
5255
run: |
5356
gh pr create \
54-
--title "Add ${{ inputs.username }} to django-commons" \
55-
--body "Fix #${{ inputs.issue_number }}" \
57+
--title "Add ${{ env.USERNAME }} to django-commons" \
58+
--body "Fix #${{ env.ISSUE_ID }}" \
5659
--base main \
57-
--head add-user/${{ inputs.username }}
60+
--head ${{ env.BRANCH_NAME }}
5861
env:
5962
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)