workflows/sync_pull-requests: more reliable triggering
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -32,6 +32,18 @@ jobs:
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
# Store the PR number for the Sync Pull Requests workflow
|
||||
- name: Save PR context
|
||||
if: matrix.node-version == '22.x'
|
||||
run: |
|
||||
mkdir -p ./context
|
||||
echo "${{ github.event.pull_request.number }}" > ./context/pr-number
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: matrix.node-version == '22.x'
|
||||
with:
|
||||
name: pr-context
|
||||
path: context/
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: use node.js ${{ matrix.node-version }}
|
||||
|
||||
@@ -7,12 +7,12 @@ on:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
# Runs when Sync Pull Requests Trigger completes (PR events like opened, labeled, reviewed)
|
||||
run:
|
||||
runs-on: ubuntu-latest
|
||||
# Only run on the trigger workflow, or if the source workflow was triggered by a pull request
|
||||
if: >
|
||||
github.event.workflow_run.name == 'Sync Pull Requests Trigger' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
github.event.workflow_run.name == 'Sync Pull Requests Trigger' ||
|
||||
github.event.workflow_run.event == 'pull_request'
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||
@@ -36,14 +36,18 @@ jobs:
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
core.setOutput('pr-number', fs.readFileSync('./context/pr-number', 'utf8').trim());
|
||||
core.setOutput('label-added', fs.readFileSync('./context/label-added', 'utf8').trim());
|
||||
core.setOutput('review-state', fs.readFileSync('./context/review-state', 'utf8').trim());
|
||||
core.setOutput('actor', fs.readFileSync('./context/actor', 'utf8').trim());
|
||||
core.setOutput('action', fs.readFileSync('./context/action', 'utf8').trim());
|
||||
function read(path, fallback) {
|
||||
try { return fs.readFileSync(path, 'utf8').trim(); }
|
||||
catch { return fallback; }
|
||||
}
|
||||
core.setOutput('pr-number', read('./context/pr-number', ''));
|
||||
core.setOutput('label-added', read('./context/label-added', ''));
|
||||
core.setOutput('review-state', read('./context/review-state', ''));
|
||||
core.setOutput('actor', read('./context/actor', ''));
|
||||
core.setOutput('action', read('./context/action', 'synchronize'));
|
||||
|
||||
- name: Backstage PR automation
|
||||
if: steps.download.outcome == 'success'
|
||||
if: steps.context.outputs.pr-number
|
||||
uses: backstage/actions/pr-automation@a3895cac2a515224a101c4a2b962b216ed0c9ac8 # v0.7.5
|
||||
with:
|
||||
app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }}
|
||||
@@ -64,35 +68,3 @@ jobs:
|
||||
Test 24.x
|
||||
Verify 22.x
|
||||
Verify 24.x
|
||||
|
||||
# Runs when CI or E2E workflows complete to update priority based on check status
|
||||
update-on-ci:
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
(github.event.workflow_run.name == 'CI' || github.event.workflow_run.name == 'E2E Linux') &&
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
github.event.workflow_run.pull_requests[0]
|
||||
steps:
|
||||
- name: Harden Runner
|
||||
uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
- name: Backstage PR automation
|
||||
uses: backstage/actions/pr-automation@a3895cac2a515224a101c4a2b962b216ed0c9ac8 # v0.7.5
|
||||
with:
|
||||
app-id: ${{ secrets.BACKSTAGE_GOALIE_APPLICATION_ID }}
|
||||
private-key: ${{ secrets.BACKSTAGE_GOALIE_PRIVATE_KEY }}
|
||||
installation-id: ${{ secrets.BACKSTAGE_GOALIE_INSTALLATION_ID }}
|
||||
project-owner: backstage
|
||||
project-number: '14'
|
||||
pr-number: ${{ github.event.workflow_run.pull_requests[0].number }}
|
||||
action: synchronize
|
||||
required-checks: |
|
||||
DCO
|
||||
E2E Linux 22.x
|
||||
E2E Linux 24.x
|
||||
Test 22.x
|
||||
Test 24.x
|
||||
Verify 22.x
|
||||
Verify 24.x
|
||||
|
||||
@@ -47,6 +47,18 @@ jobs:
|
||||
with:
|
||||
egress-policy: audit
|
||||
|
||||
# Store the PR number for the Sync Pull Requests workflow
|
||||
- name: Save PR context
|
||||
if: matrix.node-version == '22.x' && github.event_name == 'pull_request'
|
||||
run: |
|
||||
mkdir -p ./context
|
||||
echo "${{ github.event.pull_request.number }}" > ./context/pr-number
|
||||
- uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
if: matrix.node-version == '22.x' && github.event_name == 'pull_request'
|
||||
with:
|
||||
name: pr-context
|
||||
path: context/
|
||||
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
|
||||
- name: Configure Git
|
||||
|
||||
Reference in New Issue
Block a user