Skip to content

post build

post build #118

Workflow file for this run

name: post build
on:
workflow_run:
workflows:
- build
types:
- completed
jobs:
post-build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.event == 'pull_request' }}
steps:
- name: Download artifact
uses: actions/[email protected]
with:
script: |
var artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
var matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
var download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
var fs = require('fs');
fs.writeFileSync('${{github.workspace}}/pr.zip', Buffer.from(download.data));
- name: Get PR information
run: unzip pr.zip
- name: Delete label
id: label
uses: actions/[email protected]
with:
result-encoding: string
script: |
const fs = require('fs');
const issue_number = Number(fs.readFileSync('./NR'));
try {
const label_name = `${fs.readFileSync('./label')}`.trim();
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
name: label_name,
});
return label_name;
} catch (e) {
if (e.code !== 'ENOENT') throw e;
}
- name: Comment on PR
uses: actions/[email protected]
if: ${{ steps.label.outputs.result == 'wait-to-build' }}
with:
script: |
const fs = require('fs');
const issue_number = Number(fs.readFileSync('./NR'));
const comment = `${fs.readFileSync('./comment')}`.trim();
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue_number,
body: comment
});
- name: Clear artifact
uses: actions/[email protected]
with:
script: |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{github.event.workflow_run.id }},
});
const matchArtifact = artifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr"
})[0];
await github.rest.actions.deleteArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
});