|
1 | 1 | name: Port changes to PoB2 |
2 | 2 |
|
3 | 3 | on: |
4 | | - pull_request_target: |
5 | | - types: [closed] |
6 | | - |
7 | | -env: |
8 | | - LABEL_STRING: ${{ join(github.event.pull_request.labels.*.name, ',') }} |
| 4 | + pull_request_target: |
| 5 | + types: [closed] |
| 6 | + workflow_dispatch: |
| 7 | + inputs: |
| 8 | + pr_number: |
| 9 | + description: PoB1 PR number to port |
| 10 | + required: true |
| 11 | + type: number |
9 | 12 |
|
10 | 13 | jobs: |
11 | | - backport: |
12 | | - if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'pob2') |
13 | | - runs-on: ubuntu-latest |
14 | | - steps: |
15 | | - - name: Notify PathOfBuilding repo |
16 | | - uses: peter-evans/repository-dispatch@v3 |
17 | | - with: |
18 | | - token: ${{ secrets.WIRES77_PAT }} |
19 | | - repository: ${{ github.repository_owner }}/PathOfBuilding-PoE2 |
20 | | - event-type: port-changes |
21 | | - client-payload: '{"patch_url": "${{ github.event.pull_request.patch_url }}", "msg": "Apply changes from ${{ github.event.pull_request.html_url }}", "id": ${{ github.event.pull_request.number }}, "title": "${{ github.event.pull_request.title }}", "labels": "${{ env.LABEL_STRING }}", "name": "${{ github.event.pull_request.user.name }}", "user": "${{ github.event.pull_request.user.login }}"}' |
| 14 | + backport: |
| 15 | + if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'pob2')) |
| 16 | + runs-on: ubuntu-latest |
| 17 | + steps: |
| 18 | + - name: Determine PR number |
| 19 | + run: | |
| 20 | + if [ "${{ github.event_name }}" = "pull_request_target" ]; then |
| 21 | + echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> "$GITHUB_ENV" |
| 22 | + else |
| 23 | + echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> "$GITHUB_ENV" |
| 24 | + fi |
| 25 | +
|
| 26 | + - name: Fetch PR details |
| 27 | + id: payload |
| 28 | + uses: actions/github-script@v7 |
| 29 | + with: |
| 30 | + result-encoding: string |
| 31 | + script: | |
| 32 | + const pr = await github.rest.pulls.get({ |
| 33 | + owner: context.repo.owner, |
| 34 | + repo: context.repo.repo, |
| 35 | + pull_number: process.env.PR_NUMBER |
| 36 | + }); |
| 37 | + const labels = pr.data.labels.map(l => l.name).join(','); |
| 38 | + return { |
| 39 | + patch_url: pr.data.patch_url, |
| 40 | + msg: `Apply changes from ${pr.data.html_url}`, |
| 41 | + id: pr.data.number, |
| 42 | + title: pr.data.title, |
| 43 | + labels, |
| 44 | + name: pr.data.user.name || pr.data.user.login, |
| 45 | + user: pr.data.user.login, |
| 46 | + }; |
22 | 47 |
|
| 48 | + - name: Notify PathOfBuilding-PoE2 repo |
| 49 | + uses: peter-evans/repository-dispatch@v3 |
| 50 | + with: |
| 51 | + token: ${{ secrets.WIRES77_PAT }} |
| 52 | + repository: ${{ github.repository_owner }}/PathOfBuilding-PoE2 |
| 53 | + event-type: port-changes |
| 54 | + client-payload: ${{ steps.payload.outputs.result }} |
0 commit comments