--- 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 }} - name: Label precommit success uses: andymckay/labeler@1.0.3 if: ${{ github.event.workflow_run.conclusion == 'success' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "precommit:ok" remove-labels: "precommit:failed" - name: Label precommit failure uses: andymckay/labeler@1.0.3 if: ${{ github.event.workflow_run.conclusion == 'failure' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "precommit:failed" remove-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 - name: Label lint success uses: andymckay/labeler@1.0.3 if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).lint == 'success' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "lint:ok" remove-labels: "lint:failed" - name: Label lint failure uses: andymckay/labeler@1.0.3 if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).lint == 'failure' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "lint:failed" remove-labels: "lint:ok" - name: Label install success uses: andymckay/labeler@1.0.3 if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).install == 'success' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "install:ok" remove-labels: "install:failed" - name: Label install failure uses: andymckay/labeler@1.0.3 if: ${{ fromJSON(steps.get-workflow-jobs.outputs.result).install == 'failure' }} with: repo-token: ${{ steps.get-app-token.outputs.token }} issue-number: ${{ steps.source-run-info.outputs.pullRequestNumber }} add-labels: "install:failed" remove-labels: "install:ok"