2022-03-31 14:56:52 -04:00
|
|
|
---
|
|
|
|
name: "Metadata: Label pull requests CI status"
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_run:
|
|
|
|
workflows:
|
|
|
|
- "Pull Request: Validate"
|
|
|
|
types:
|
|
|
|
- completed
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
label-ci-status:
|
|
|
|
name: Label CI status
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: Checkout
|
2022-10-05 08:55:34 -04:00
|
|
|
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
|
2022-03-31 14:56:52 -04:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
|
|
|
|
- name: Download workflow artifact
|
2022-08-30 07:15:43 -04:00
|
|
|
uses: dawidd6/action-download-artifact@7847792dd435a50521b8e3bd3576dae7459d1fa8 # tag=v2.23.0
|
2022-03-31 14:56:52 -04:00
|
|
|
with:
|
|
|
|
github_token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
workflow: pr-validate.yaml
|
|
|
|
run_id: ${{ github.event.workflow_run.id }}
|
|
|
|
name: pr_metadata
|
|
|
|
path: ./pr_metadata
|
|
|
|
|
|
|
|
- name: Read the pr_number file
|
|
|
|
id: pr_num_reader
|
2022-10-12 08:20:50 -04:00
|
|
|
uses: juliangruber/read-file-action@02bbba9876a8f870efd4ad64e3b9088d3fb94d4b # tag=v1.1.6
|
2022-03-31 14:56:52 -04:00
|
|
|
with:
|
|
|
|
path: ./pr_metadata/pr_number.txt
|
|
|
|
|
|
|
|
- name: "Get workflow job status"
|
2022-10-11 14:18:48 -04:00
|
|
|
uses: actions/github-script@100527700e8b29ca817ac0e0dfbfc5e8ff38edda # tag=v6
|
2022-03-31 14:56:52 -04:00
|
|
|
id: get-workflow-jobs
|
|
|
|
with:
|
|
|
|
github-token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
# https://mhagemann.medium.com/the-ultimate-way-to-slugify-a-url-string-in-javascript-b8e4a0d849e1
|
|
|
|
script: |
|
|
|
|
function slugify(string) {
|
|
|
|
const a = 'àáâäæãåāăąçćčđďèéêëēėęěğǵḧîïíīįìıİłḿñńǹňôöòóœøōõőṕŕřßśšşșťțûüùúūǘůűųẃẍÿýžźż·/_,:;'
|
|
|
|
const b = 'aaaaaaaaaacccddeeeeeeeegghiiiiiiiilmnnnnoooooooooprrsssssttuuuuuuuuuwxyyzzz------'
|
|
|
|
const p = new RegExp(a.split('').join('|'), 'g')
|
|
|
|
return string.toString().toLowerCase()
|
|
|
|
.replace(/\s+/g, '-') // Replace spaces with -
|
|
|
|
.replace(p, c => b.charAt(a.indexOf(c))) // Replace special characters
|
|
|
|
.replace(/&/g, '-and-') // Replace & with 'and'
|
|
|
|
.replace(/[^\w\-]+/g, '') // Remove all non-word characters
|
|
|
|
.replace(/\-\-+/g, '-') // Replace multiple - with single -
|
|
|
|
.replace(/^-+/, '') // Trim - from start of text
|
|
|
|
.replace(/-+$/, '') // Trim - from end of text
|
|
|
|
}
|
|
|
|
let result = new Object
|
|
|
|
const wfJobs = await github.rest.actions.listJobsForWorkflowRun({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
run_id: context.payload.workflow_run.id,
|
|
|
|
})
|
|
|
|
for (const job of wfJobs.data.jobs) {
|
|
|
|
result[slugify(job.name)] = job.conclusion
|
|
|
|
}
|
|
|
|
console.log(result)
|
|
|
|
return result
|
|
|
|
- name: Label pre-commit status
|
|
|
|
uses: ./.github/actions/label-from-status
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
issue-number: ${{ steps.pr_num_reader.outputs.content }}
|
|
|
|
prefix: precommit
|
|
|
|
job-status: |-
|
|
|
|
${{ fromJSON(steps.get-workflow-jobs.outputs.result).pre-commit-check-run-pre-commit-checks || 'skipped' }}
|
|
|
|
remove-on-skipped: true
|
|
|
|
|
|
|
|
#- name: Label changelog status
|
|
|
|
# uses: ./.github/actions/label-from-status
|
|
|
|
# with:
|
|
|
|
# token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
# issue-number: ${{ steps.pr_num_reader.outputs.content }}
|
|
|
|
# prefix: changelog
|
|
|
|
# job-status: |-
|
|
|
|
# ${{ fromJSON(steps.get-workflow-jobs.outputs.result).charts-changelog-validate-changelog || 'skipped' }}
|
|
|
|
# remove-on-skipped: true
|
|
|
|
|
|
|
|
- name: Label chart lint status
|
|
|
|
uses: ./.github/actions/label-from-status
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
issue-number: ${{ steps.pr_num_reader.outputs.content }}
|
|
|
|
prefix: lint
|
|
|
|
job-status: |-
|
|
|
|
${{ fromJSON(steps.get-workflow-jobs.outputs.result).charts-lint-lint-successful || 'skipped' }}
|
|
|
|
remove-on-skipped: true
|
|
|
|
|
|
|
|
- name: Label chart install status
|
|
|
|
uses: ./.github/actions/label-from-status
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.BOT_TOKEN }}
|
|
|
|
issue-number: ${{ steps.pr_num_reader.outputs.content }}
|
|
|
|
prefix: install
|
|
|
|
job-status: |-
|
|
|
|
${{ fromJSON(steps.get-workflow-jobs.outputs.result).charts-test-install-successful || 'skipped' }}
|
|
|
|
remove-on-skipped: true
|