|
| 1 | +name: PR Project Automation |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, ready_for_review, review_requested, closed] |
| 6 | + pull_request_review: |
| 7 | + types: [submitted] |
| 8 | + |
| 9 | +jobs: |
| 10 | + automate_project_stages: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + |
| 13 | + steps: |
| 14 | + - name: Checkout repository |
| 15 | + uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Install GitHub CLI |
| 18 | + run: | |
| 19 | + sudo apt-get update |
| 20 | + sudo apt-get install -y gh |
| 21 | +
|
| 22 | + - name: Move PR to To Do |
| 23 | + if: github.event.action == 'opened' |
| 24 | + env: |
| 25 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 26 | + run: | |
| 27 | + gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "To Do") | .id' > card_id.txt |
| 28 | + CARD_ID=$(cat card_id.txt) |
| 29 | + if [ -n "$CARD_ID" ]; then |
| 30 | + gh project card-move "$CARD_ID" --column "To Do" |
| 31 | + fi |
| 32 | +
|
| 33 | + - name: Move PR to In Progress |
| 34 | + if: github.event.action == 'ready_for_review' |
| 35 | + env: |
| 36 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 37 | + run: | |
| 38 | + gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "In Progress") | .id' > card_id.txt |
| 39 | + CARD_ID=$(cat card_id.txt) |
| 40 | + if [ -n "$CARD_ID" ]; then |
| 41 | + gh project card-move "$CARD_ID" --column "In Progress" |
| 42 | + fi |
| 43 | +
|
| 44 | + - name: Move PR to Review |
| 45 | + if: github.event_name == 'pull_request_review' || github.event.action == 'review_requested' |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + run: | |
| 49 | + gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "Review") | .id' > card_id.txt |
| 50 | + CARD_ID=$(cat card_id.txt) |
| 51 | + if [ -n "$CARD_ID" ]; then |
| 52 | + gh project card-move "$CARD_ID" --column "Review" |
| 53 | + fi |
| 54 | +
|
| 55 | + - name: Move PR to Done |
| 56 | + if: github.event.action == 'closed' |
| 57 | + env: |
| 58 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + run: | |
| 60 | + gh pr view ${{ github.event.pull_request.number }} --json projectCards --jq '.projectCards[] | select(.name == "Done") | .id' > card_id.txt |
| 61 | + CARD_ID=$(cat card_id.txt) |
| 62 | + if [ -n "$CARD_ID" ]; then |
| 63 | + gh project card-move "$CARD_ID" --column "Done" |
| 64 | + fi |
0 commit comments