|
1 | 1 | name: 'Auto Assign PR' |
| 2 | + |
2 | 3 | on: |
3 | | - workflow_call: |
4 | | - pull_request: |
5 | | - types: [opened, reopened] |
| 4 | + workflow_run: |
| 5 | + workflows: ["Pull Request Opened"] |
| 6 | + types: |
| 7 | + - completed |
6 | 8 |
|
7 | 9 | jobs: |
| 10 | + log-info: |
| 11 | + name: "Add reviewers to PR" |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: "echo variables" |
| 15 | + run: | |
| 16 | + echo \"${{ github.event.workflow_run.event }}\" |
| 17 | + echo \"${{ github.event.pull_request.types }}\" |
| 18 | + echo \"${{ github.actor }}\" |
| 19 | +
|
8 | 20 | add-reviewers: |
9 | 21 | name: "Add reviewers to PR" |
10 | | - if: ${{ github.actor != 'dependabot[bot]' }} |
| 22 | + if: > |
| 23 | + github.event.workflow_run.event == 'pull_request' && |
| 24 | + github.actor != 'dependabot[bot]' |
| 25 | + env: |
| 26 | + GITHUB_TOKEN: ${{ secrets.MP_SEMANTIC_RELEASE_BOT }} |
| 27 | + GIT_AUTHOR_NAME: mparticle-automation |
| 28 | + GIT_AUTHOR_EMAIL: [email protected] |
| 29 | + GIT_COMMITTER_NAME: mparticle-automation |
| 30 | + GIT_COMMITTER_EMAIL: [email protected] |
11 | 31 | runs-on: ubuntu-latest |
12 | 32 | steps: |
13 | | - - name: "Check PR title" |
14 | | - id: is-docs |
15 | | - if: > |
16 | | - startsWith(github.event.pull_request.title, 'docs:') |
17 | | - run: | |
18 | | - OUTPUT=true |
19 | | - echo "::set-output name=isDocs::$OUTPUT" |
20 | | - - name: "echo isDocs" |
21 | | - run: | |
22 | | - echo ${{ steps.is-docs.outputs.isDocs }} |
23 | | - - name: "PR title is docs" |
24 | | - if: ${{steps.is-docs.outputs.isDocs == 'true'}} |
25 | | - uses: pozil/auto-assign-issue@v1 |
26 | | - with: |
27 | | - teams: docs-admin |
28 | | - numOfAssignee: 1 |
29 | | - allowSelfAssign: false |
30 | | - repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}} |
31 | | - - name: "PR title is invalid" |
32 | | - if: ${{ steps.is-docs.outputs.isDocs != 'true'}} |
33 | | - uses: pozil/auto-assign-issue@v1 |
34 | | - with: |
35 | | - teams: android-triage |
36 | | - numOfAssignee: 1 |
37 | | - allowSelfAssign: false |
38 | | - repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}} |
| 33 | + - name: 'Print Event' |
| 34 | + run: | |
| 35 | + echo ${{ github.event.workflow_run.event }} |
| 36 | + - name: 'Download artifact' |
| 37 | + |
| 38 | + with: |
| 39 | + script: | |
| 40 | + var artifacts = await github.actions.listWorkflowRunArtifacts({ |
| 41 | + owner: context.repo.owner, |
| 42 | + repo: context.repo.repo, |
| 43 | + run_id: ${{ github.event.workflow_run.id }}, |
| 44 | + }); |
| 45 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 46 | + return artifact.name == "pr" |
| 47 | + })[0]; |
| 48 | + var download = await github.actions.downloadArtifact({ |
| 49 | + owner: context.repo.owner, |
| 50 | + repo: context.repo.repo, |
| 51 | + artifact_id: matchArtifact.id, |
| 52 | + archive_format: 'zip', |
| 53 | + }); |
| 54 | + var fs = require('fs'); |
| 55 | + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); |
| 56 | + - run: unzip pr.zip |
| 57 | + - name: 'Find PR Title' |
| 58 | + id: find-pr |
| 59 | + uses: actions/github-script@v3 |
| 60 | + with: |
| 61 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + script: | |
| 63 | + var fs = require('fs'); |
| 64 | + var titleString = String(fs.readFileSync('./NR')); |
| 65 | + echo "::set-output name=title::titleString" |
| 66 | + - name: "Log PR Title" |
| 67 | + run: | |
| 68 | + echo \"${{ steps.find-pr.outputs.title }}\" |
| 69 | +
|
| 70 | + - name: "Check PR title" |
| 71 | + id: is-docs |
| 72 | + if: > |
| 73 | + startsWith(${{ steps.find-pr.outputs.title }}, 'docs:') |
| 74 | + run: | |
| 75 | + OUTPUT=true |
| 76 | + echo "::set-output name=isDocs::$OUTPUT" |
| 77 | + - name: "echo isDocs" |
| 78 | + run: | |
| 79 | + echo ${{ steps.is-docs.outputs.isDocs }} |
| 80 | + - name: "PR title is docs" |
| 81 | + if: ${{steps.is-docs.outputs.isDocs == 'true'}} |
| 82 | + uses: pozil/auto-assign-issue@v1 |
| 83 | + with: |
| 84 | + teams: docs-triage |
| 85 | + numOfAssignee: 1 |
| 86 | + allowSelfAssign: false |
| 87 | + repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}} |
| 88 | + - name: "PR title is not docs" |
| 89 | + if: ${{ steps.is-docs.outputs.isDocs != 'true'}} |
| 90 | + uses: pozil/auto-assign-issue@v1 |
| 91 | + with: |
| 92 | + teams: android-triage |
| 93 | + numOfAssignee: 1 |
| 94 | + allowSelfAssign: false |
| 95 | + repo-token: ${{ secrets.MP_SEMANTIC_RELEASE_BOT}} |
0 commit comments