Skip to content

Commit 37d9137

Browse files
authored
Update pr-in-progress.yml
1 parent 70f1f76 commit 37d9137

File tree

1 file changed

+40
-6
lines changed

1 file changed

+40
-6
lines changed
Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: Move PR to In Progress
1+
name: PR Project Automation
22

33
on:
44
pull_request:
5-
types: [opened]
5+
types: [opened, ready_for_review, review_requested, closed]
6+
pull_request_review:
7+
types: [submitted]
68

79
jobs:
8-
move_pr_to_in_progress:
10+
automate_project_stages:
911
runs-on: ubuntu-latest
1012

1113
steps:
@@ -17,18 +19,50 @@ jobs:
1719
sudo apt-get update
1820
sudo apt-get install -y gh
1921
20-
- name: Authenticate GitHub CLI
22+
- name: Move PR to To Do
23+
if: github.event.action == 'opened'
2124
env:
2225
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2326
run: |
24-
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
27+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
28+
gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "To Do") | .id' > card_id.txt
29+
CARD_ID=$(cat card_id.txt)
30+
if [ -n "$CARD_ID" ]; then
31+
gh project card-move "$CARD_ID" --column "To Do"
32+
fi
2533
2634
- name: Move PR to In Progress
35+
if: github.event.action == 'ready_for_review'
2736
env:
2837
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2938
run: |
30-
gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "To Do") | .id' > card_id.txt
39+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
40+
gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "In Progress") | .id' > card_id.txt
3141
CARD_ID=$(cat card_id.txt)
3242
if [ -n "$CARD_ID" ]; then
3343
gh project card-move "$CARD_ID" --column "In Progress"
3444
fi
45+
46+
- name: Move PR to Review
47+
if: github.event_name == 'pull_request_review' || github.event.action == 'review_requested'
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
run: |
51+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
52+
gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "Review") | .id' > card_id.txt
53+
CARD_ID=$(cat card_id.txt)
54+
if [ -n "$CARD_ID" ]; then
55+
gh project card-move "$CARD_ID" --column "Review"
56+
fi
57+
58+
- name: Move PR to Done
59+
if: github.event.action == 'closed'
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
run: |
63+
gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
64+
gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "Done") | .id' > card_id.txt
65+
CARD_ID=$(cat card_id.txt)
66+
if [ -n "$CARD_ID" ]; then
67+
gh project card-move "$CARD_ID" --column "Done"
68+
fi

0 commit comments

Comments
 (0)