Skip to content

Commit

Permalink
Merge pull request DroidKaigi#501 from DroidKaigi/feature/fix_assign_…
Browse files Browse the repository at this point in the history
…ios_reviewers_workflow
  • Loading branch information
shin-usu authored Aug 16, 2024
2 parents e066410 + bb062ed commit e7cd75e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/ios-assign-reviewers.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
name: Auto assign iOS PR reviewers

on:
pull_request:
types: [opened, ready_for_review, labeled]
workflow_run:
workflows: ["save-pr-number-for-ios-assign-reviewers"]
types:
- completed

permissions:
actions: read # for downloading artifacts
contents: read # for accessing repository contents
pull-requests: write # for assign reviewers

jobs:
reviewers-assign:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
if: ${{ github.event.workflow_run.conclusion == 'success' }}

timeout-minutes: 5
steps:
- name: Download PR number
uses: dawidd6/action-download-artifact@246dbf436b23d7c49e21a7ab8204ca9ecd1fe615 # v2.27.0
with:
name: pr_number
path: ./
run_id: ${{ github.event.workflow_run.id }}

- name: Read PR number
id: pr_number
run: echo "::set-output name=number::$(cat pr_number.txt)"

- name: Assign reviewers
uses: actions/github-script@v7
if: contains(github.event.pull_request.labels.*.name, 'type:iOS 🍎') && github.event.pull_request.draft == false
env:
IOS_REVIEWERS: ${{ vars.IOS_REVIEWERS }}
PULL_NUMBER: ${{ steps.pr_number.outputs.number }}
with:
script: |
const { IOS_REVIEWERS } = process.env
Expand All @@ -27,6 +43,6 @@ jobs:
await github.rest.pulls.requestReviewers({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
pull_number: PULL_NUMBER,
reviewers
});
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
permissions:
actions: read # for downloading artifacts
contents: read # for accessing repository contents
pull-requests: write # for removing labels from pull requests
pull-requests: write # for add labels to pull requests

jobs:
label:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/save-pr-number-for-ios-assign-reviewers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: save-pr-number-for-ios-assign-reviewers

on:
pull_request:
types: [opened, ready_for_review, labeled]

jobs:
save_pr_number:
runs-on: ubuntu-latest
if: contains(github.event.pull_request.labels.*.name, 'type:iOS 🍎') && github.event.pull_request.draft == false

steps:
- name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} > pr_number.txt
- name: Upload PR number
uses: actions/upload-artifact@v2
with:
name: pr_number
path: pr_number.txt

0 comments on commit e7cd75e

Please sign in to comment.