|
| 1 | +name: Pull Request Assigner Completion Workflow |
| 2 | + |
| 3 | +# read-write repo token |
| 4 | +# access to secrets |
| 5 | +on: |
| 6 | + workflow_run: |
| 7 | + workflows: ["Pull Request Assigner"] |
| 8 | + types: |
| 9 | + - completed |
| 10 | + |
| 11 | +permissions: |
| 12 | + contents: read |
| 13 | + |
| 14 | +jobs: |
| 15 | + assignment: |
| 16 | + name: Pull Request Assignment |
| 17 | + runs-on: ubuntu-24.04 |
| 18 | + if: > |
| 19 | + github.event.workflow_run.event == 'pull_request' && |
| 20 | + github.event.workflow_run.conclusion == 'success' |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: 'Download artifact' |
| 24 | + |
| 25 | + with: |
| 26 | + script: | |
| 27 | + var artifacts = await github.actions.listWorkflowRunArtifacts({ |
| 28 | + owner: context.repo.owner, |
| 29 | + repo: context.repo.repo, |
| 30 | + run_id: ${{github.event.workflow_run.id }}, |
| 31 | + }); |
| 32 | + var matchArtifact = artifacts.data.artifacts.filter((artifact) => { |
| 33 | + return artifact.name == "pr" |
| 34 | + })[0]; |
| 35 | + var download = await github.actions.downloadArtifact({ |
| 36 | + owner: context.repo.owner, |
| 37 | + repo: context.repo.repo, |
| 38 | + artifact_id: matchArtifact.id, |
| 39 | + archive_format: 'zip', |
| 40 | + }); |
| 41 | + var fs = require('fs'); |
| 42 | + fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data)); |
| 43 | + - run: unzip pr.zip |
| 44 | + |
| 45 | + - name: Check out source code |
| 46 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 47 | + with: |
| 48 | + fetch-depth: 0 |
| 49 | + persist-credentials: false |
| 50 | + |
| 51 | + - name: Set up Python |
| 52 | + uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 53 | + with: |
| 54 | + python-version: 3.12 |
| 55 | + cache: pip |
| 56 | + cache-dependency-path: scripts/requirements-actions.txt |
| 57 | + |
| 58 | + - name: Install Python packages |
| 59 | + run: | |
| 60 | + pip install -r scripts/requirements-actions.txt --require-hashes |
| 61 | + |
| 62 | + - name: Run assignment script |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.ZB_PR_ASSIGNER_GITHUB_TOKEN }} |
| 65 | + run: | |
| 66 | + FLAGS="-v" |
| 67 | + FLAGS+=" -o ${{ github.event.repository.owner.login }}" |
| 68 | + FLAGS+=" -r ${{ github.event.repository.name }}" |
| 69 | + FLAGS+=" -M MAINTAINERS.yml" |
| 70 | + if [ "${{ github.event_name }}" = "pull_request_target" ]; then |
| 71 | + FLAGS+=" -P ${{ github.event.pull_request.number }} -c origin/${{ github.base_ref }}.." |
| 72 | + elif [ "${{ github.event_name }}" = "issues" ]; then |
| 73 | + FLAGS+=" -I ${{ github.event.issue.number }}" |
| 74 | + elif [ "${{ github.event_name }}" = "schedule" ]; then |
| 75 | + FLAGS+=" --modules" |
| 76 | + else |
| 77 | + echo "Unknown event: ${{ github.event_name }}" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + |
| 81 | + python3 scripts/set_assignees.py $FLAGS |
0 commit comments