diff --git a/.github/workflows/metadata-label-pr-ci-status.yaml b/.github/workflows/metadata-label-pr-ci-status.yaml index aa7a85b7..9b5ff6e6 100644 --- a/.github/workflows/metadata-label-pr-ci-status.yaml +++ b/.github/workflows/metadata-label-pr-ci-status.yaml @@ -105,12 +105,6 @@ jobs: console.log(result) return result - - name: Get result - run: | - echo "${{steps.get-workflow-jobs.outputs.result}}" - echo "" - echo "${{steps.get-workflow-jobs.outputs.result.lint}}" - # # CI Passed # - name: "add label: ok" # uses: actions-ecosystem/action-add-labels@v1 @@ -128,19 +122,25 @@ jobs: # number: ${{ needs.get-info.outputs.pullRequestNumber }} # labels: "lint: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: ${{ needs.get-info.outputs.pullRequestNumber }} - # labels: "lint: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: ${{ needs.get-info.outputs.pullRequestNumber }} - # labels: "lint:ok" + - 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] + })