workflow: Fix second step of PR review labeling (#792)

This commit is contained in:
MonsterDruide1 2025-10-31 18:06:49 +01:00 committed by GitHub
parent 8f4afefbf4
commit a5111a23e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -14,18 +14,41 @@ jobs:
review_update:
runs-on: ubuntu-latest
steps:
- name: Download review info
uses: actions/download-artifact@v4
- name: 'Download artifact'
uses: actions/github-script@v8
with:
name: review-event
path: .
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "review-event"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
const fs = require('fs');
const path = require('path');
const temp = '${{ runner.temp }}/artifacts';
if (!fs.existsSync(temp)){
fs.mkdirSync(temp);
}
fs.writeFileSync(path.join(temp, 'review-event.zip'), Buffer.from(download.data));
- name: 'Unzip artifact'
run: unzip "${{ runner.temp }}/artifacts/review-event.zip" -d "${{ runner.temp }}/artifacts"
- name: Update status labels based on review
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const data = JSON.parse(fs.readFileSync('event.json', 'utf8'));
const data = JSON.parse(fs.readFileSync('${{ runner.temp }}/artifacts/event.json', 'utf8'));
const owner = data.repository.owner;
const repo = data.repository.name;