2021-07-24 11:03:17 +00:00
|
|
|
---
|
|
|
|
name: "Metadata: Label pull requests CI status"
|
|
|
|
|
|
|
|
on:
|
2021-07-24 12:25:54 +00:00
|
|
|
workflow_run:
|
|
|
|
workflows:
|
2022-01-21 13:43:14 +00:00
|
|
|
- "Pre-commit consistency check"
|
|
|
|
- "Charts: Validate"
|
2021-07-24 12:25:54 +00:00
|
|
|
types:
|
2022-01-21 13:43:14 +00:00
|
|
|
- completed
|
2021-07-24 11:03:17 +00:00
|
|
|
|
|
|
|
jobs:
|
2021-07-24 12:22:58 +00:00
|
|
|
label-precommit:
|
|
|
|
name: Label pre-commit status
|
|
|
|
runs-on: ubuntu-20.04
|
2021-07-24 12:41:27 +00:00
|
|
|
if: "${{ github.event.workflow.name == 'Pre-commit consistency check' }}"
|
2021-07-24 12:22:58 +00:00
|
|
|
steps:
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Generate Token
|
|
|
|
uses: tibdex/github-app-token@v1
|
|
|
|
id: generate-token
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
|
|
|
|
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
|
2021-07-24 11:37:05 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: "Get information about the origin 'CI' run"
|
|
|
|
uses: potiuk/get-workflow-origin@v1_3
|
|
|
|
id: source-run-info
|
|
|
|
with:
|
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
sourceRunId: ${{ github.event.workflow_run.id }}
|
2021-07-24 12:54:57 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label precommit success
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "precommit:ok"
|
|
|
|
remove-labels: "precommit:failed"
|
2021-07-24 12:49:41 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label precommit failure
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "precommit:failed"
|
|
|
|
remove-labels: "precommit:ok"
|
2021-07-24 11:45:11 +00:00
|
|
|
|
2021-07-24 12:41:27 +00:00
|
|
|
label-lint-install:
|
|
|
|
name: Label lint and install status
|
|
|
|
runs-on: ubuntu-20.04
|
2022-01-06 10:41:00 +00:00
|
|
|
if: "${{ github.event.workflow.name == 'Charts: Validate' }}"
|
2021-07-24 12:41:27 +00:00
|
|
|
steps:
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Generate Token
|
|
|
|
uses: tibdex/github-app-token@v1
|
|
|
|
id: generate-token
|
|
|
|
with:
|
|
|
|
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
|
|
|
|
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
|
2021-07-24 11:45:11 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: "Get information about the origin 'CI' run"
|
|
|
|
uses: potiuk/get-workflow-origin@v1_3
|
|
|
|
id: source-run-info
|
|
|
|
with:
|
|
|
|
token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
sourceRunId: ${{ github.event.workflow_run.id }}
|
2021-07-24 12:54:57 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: "Get workflow job status"
|
|
|
|
uses: actions/github-script@v5
|
|
|
|
id: get-workflow-jobs
|
|
|
|
with:
|
|
|
|
github-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
script: |
|
|
|
|
let result = new Object
|
2021-07-24 13:37:54 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
const wfJobs = await github.rest.actions.listJobsForWorkflowRun({
|
|
|
|
owner: context.repo.owner,
|
|
|
|
repo: context.repo.repo,
|
|
|
|
run_id: context.payload.workflow_run.id,
|
|
|
|
})
|
2021-07-24 13:25:26 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
for (const job of wfJobs.data.jobs) {
|
|
|
|
if (job.name === 'Lint successful') {
|
|
|
|
result['lint'] = job.conclusion
|
|
|
|
} else if (job.name === 'Install successful') {
|
|
|
|
result['install'] = job.conclusion
|
|
|
|
}
|
2021-07-24 13:25:26 +00:00
|
|
|
}
|
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
console.log(result)
|
|
|
|
return result
|
2021-07-24 13:03:27 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label lint success
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).lint == 'success' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "lint:ok"
|
|
|
|
remove-labels: "lint:failed"
|
2021-07-24 14:36:47 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label lint failure
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).lint == 'failure' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "lint:failed"
|
|
|
|
remove-labels: "lint:ok"
|
2021-07-24 14:36:47 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label install success
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).install == 'success' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "install:ok"
|
|
|
|
remove-labels: "install:failed"
|
2021-07-24 14:36:47 +00:00
|
|
|
|
2022-01-21 13:43:14 +00:00
|
|
|
- name: Label install failure
|
|
|
|
uses: andymckay/labeler@1.0.4
|
|
|
|
if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).install == 'failure' }}
|
|
|
|
with:
|
|
|
|
repo-token: ${{ steps.generate-token.outputs.token }}
|
|
|
|
issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
|
|
add-labels: "install:failed"
|
|
|
|
remove-labels: "install:ok"
|