Skip to content

Validation Feedback #190

Validation Feedback

Validation Feedback #190

Workflow file for this run

name: Validation Feedback
on:
workflow_run:
workflows: [Validate Packages]
types: [completed]
permissions:
actions: read
pull-requests: write
jobs:
feedback:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- run: echo 'The triggering workflow passed'
- name: 'Download pre analysis artifacts'
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
script: |
const fs = require('fs');
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 == "pr-artifacts"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr-artifacts.zip`, Buffer.from(download.data));
- name: 'Unzip artifacts'
run: unzip pr-artifacts.zip
- name: Retrieve PR number'
id: pr-number
run: |
PR_NUMBER=$(cat pr-number)
echo "$PR_NUMBER"
echo "pr_number=$PR_NUMBER" >> $GITHUB_ENV
- name: Sanitize validation logs
id: sanitize-validate-log
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
script: |
const fs = require('fs')
let validateLog = fs.readFileSync('validate.log')
return validateLog.toString()
.replaceAll("`", "")
.replaceAll("~", "")
.replaceAll("<", "")
.replaceAll(">", "")
- name: Publish validation success report
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
PR_NUMBER: ${{ env.pr_number }}
VALIDATE_LOG : ${{ steps.sanitize-validate-log.outputs.result }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { PR_NUMBER, VALIDATE_LOG } = process.env
const VALIDATE_LOG_DISPLAY = VALIDATE_LOG.replaceAll("\\n", "\n")
github.rest.issues.createComment({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:white_check_mark: Packages has been verified and are valid
<details>
<summary>View validation details</summary>
~~~
${VALIDATE_LOG_DISPLAY}
~~~
</details>
`
})
- name: Publish validation error report
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
env:
PR_NUMBER: ${{ env.pr_number }}
VALIDATE_LOG : ${{ steps.sanitize-validate-log.outputs.result }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { PR_NUMBER, VALIDATE_LOG } = process.env
const VALIDATE_LOG_DISPLAY = VALIDATE_LOG.replaceAll("\\n", "\n")
github.rest.issues.createComment({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
body: `:x: Packages has been verified and are flagged as invalid
<details>
<summary>View validation details</summary>
~~~
${VALIDATE_LOG_DISPLAY}
~~~
</details>
`
})
- name: Label success job
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
if: ${{ github.event.workflow_run.conclusion == 'success' }}
env:
PR_NUMBER: ${{ env.pr_number }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { PR_NUMBER } = process.env
github.rest.issues.addLabels({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Valid', 'Wait-Approval']
}).catch((e) => {})
github.rest.issues.removeLabel({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Invalid'
}).catch((e) => {})
- name: Label failure job
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
env:
PR_NUMBER: ${{ env.pr_number }}
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const { PR_NUMBER } = process.env
github.rest.issues.addLabels({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['Invalid']
}).catch((e) => {})
github.rest.issues.removeLabel({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Valid'
}).catch((e) => {})
github.rest.issues.removeLabel({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Wait-Approval'
}).catch((e) => {})