mirror of
https://github.com/k8s-at-home/charts.git
synced 2025-01-24 07:59:02 +00:00
fe2b0a8eb1
Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev>
147 lines
5.0 KiB
YAML
147 lines
5.0 KiB
YAML
---
|
|
name: "Metadata: Label pull requests CI status"
|
|
|
|
on:
|
|
workflow_run:
|
|
workflows:
|
|
- "Pre-commit consistency check"
|
|
- "Charts: Lint and test"
|
|
types:
|
|
- completed
|
|
|
|
jobs:
|
|
label-precommit:
|
|
name: Label pre-commit status
|
|
runs-on: ubuntu-20.04
|
|
if: "${{ github.event.workflow.name == 'Pre-commit consistency check' }}"
|
|
steps:
|
|
- uses: getsentry/action-github-app-token@v1
|
|
id: get-app-token
|
|
with:
|
|
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
|
|
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
|
|
|
|
- name: "Get information about the origin 'CI' run"
|
|
uses: potiuk/get-workflow-origin@v1_3
|
|
id: source-run-info
|
|
with:
|
|
token: ${{ steps.get-app-token.outputs.token }}
|
|
sourceRunId: ${{ github.event.workflow_run.id }}
|
|
|
|
# CI Passed
|
|
- name: "add label: ok"
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
with:
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
labels: "precommit:ok"
|
|
|
|
- name: "remove label: failed"
|
|
uses: actions-ecosystem/action-remove-labels@v1
|
|
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
with:
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
labels: "precommit:failed"
|
|
|
|
# CI Failed
|
|
- name: "add label: failed"
|
|
uses: actions-ecosystem/action-add-labels@v1
|
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
|
with:
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
labels: "precommit:failed"
|
|
|
|
- name: "remove label: ok"
|
|
uses: actions-ecosystem/action-remove-labels@v1
|
|
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
|
|
with:
|
|
github_token: ${{ steps.get-app-token.outputs.token }}
|
|
number: ${{ steps.source-run-info.outputs.pullRequestNumber }}
|
|
labels: "precommit:ok"
|
|
|
|
label-lint-install:
|
|
name: Label lint and install status
|
|
runs-on: ubuntu-20.04
|
|
if: "${{ github.event.workflow.name == 'Charts: Lint and test' }}"
|
|
steps:
|
|
- uses: getsentry/action-github-app-token@v1
|
|
id: get-app-token
|
|
with:
|
|
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
|
|
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
|
|
|
|
- name: "Get information about the origin 'CI' run"
|
|
uses: potiuk/get-workflow-origin@v1_3
|
|
id: source-run-info
|
|
with:
|
|
token: ${{ steps.get-app-token.outputs.token }}
|
|
sourceRunId: ${{ github.event.workflow_run.id }}
|
|
|
|
- name: "Get workflow job status"
|
|
uses: actions/github-script@v4
|
|
id: get-workflow-jobs
|
|
with:
|
|
github-token: ${{ steps.get-app-token.outputs.token }}
|
|
script: |
|
|
let result = new Object
|
|
|
|
const wfJobs = await github.actions.listJobsForWorkflowRun({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
run_id: context.payload.workflow_run.id,
|
|
})
|
|
|
|
for (const job of wfJobs.data.jobs) {
|
|
if (job.name === 'Lint charts') {
|
|
result['lint'] = job.conclusion
|
|
} else if (job.name === 'Install successful') {
|
|
result['install'] = job.conclusion
|
|
}
|
|
}
|
|
|
|
console.log(result)
|
|
return result
|
|
|
|
# # CI Passed
|
|
# - name: "add label: ok"
|
|
# uses: actions-ecosystem/action-add-labels@v1
|
|
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
# with:
|
|
# github_token: ${{ steps.get-app-token.outputs.token }}
|
|
# number: ${{ needs.get-info.outputs.pullRequestNumber }}
|
|
# labels: "lint:ok"
|
|
|
|
# - name: "remove label: failed"
|
|
# uses: actions-ecosystem/action-remove-labels@v1
|
|
# if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
# with:
|
|
# github_token: ${{ steps.get-app-token.outputs.token }}
|
|
# number: ${{ needs.get-info.outputs.pullRequestNumber }}
|
|
# labels: "lint:failed"
|
|
|
|
- name: "Lint failed"
|
|
uses: actions/github-script@v4
|
|
if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).lint == 'failure' }}
|
|
env:
|
|
LABEL_OK: "lint:ok"
|
|
LABEL_FAILED: "lint:failed"
|
|
with:
|
|
github-token: ${{ steps.get-app-token.outputs.token }}
|
|
script: |
|
|
const { LABEL_OK, LABEL_FAILED } = process.env
|
|
github.issues.addLabels({
|
|
issue_number: context.needs.get-info.outputs.pullRequestNumber,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: [LABEL_FAILED]
|
|
})
|
|
github.issues.removeLabel({
|
|
issue_number: context.needs.get-info.outputs.pullRequestNumber,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
name: [LABEL_OK]
|
|
})
|