diff --git a/.github/actions/fork-result-label/action.yml b/.github/actions/fork-result-label/action.yml new file mode 100644 index 0000000000..38dd88ca9b --- /dev/null +++ b/.github/actions/fork-result-label/action.yml @@ -0,0 +1,35 @@ +name: Add label to PR with CI results +description: Add label to PR with CI results +inputs: + SUCCESS: + description: Text of the comment + required: true + PULL_REQUEST_NUMBER: + description: Pull request id + required: false + default: "0" +runs: + using: "composite" + steps: + - name: delete success label + uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 + with: + labels: "CI Passed" + number: ${{ inputs.PULL_REQUEST_NUMBER }} + - name: delete fail label + uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 + with: + labels: "CI Failed" + number: ${{ inputs.PULL_REQUEST_NUMBER }} + - name: adding success label + uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8 + if: ${{ inputs.SUCCESS == 'true' }} + with: + labels: "CI Passed" + number: ${{ inputs.PULL_REQUEST_NUMBER }} + - name: adding fail label + uses: actions-ecosystem/action-add-labels@bd52874380e3909a1ac983768df6976535ece7f8 + if: ${{ inputs.SUCCESS == 'false' }} + with: + labels: "CI Failed" + number: ${{ inputs.PULL_REQUEST_NUMBER }} diff --git a/.github/workflows/add-label.yml b/.github/workflows/add-label.yml new file mode 100644 index 0000000000..01aeb5b5af --- /dev/null +++ b/.github/workflows/add-label.yml @@ -0,0 +1,66 @@ +name: Test adding label to pr + +concurrency: + group: ${{ github.workflow }}-${{ github.event.workflow_run.id }} + cancel-in-progress: true + +on: + workflow_run: + workflows: ["Build PR From Fork"] + types: ["completed"] + branches-ignore: ["main"] + +jobs: + prepare_jobs: + runs-on: ubuntu-latest + outputs: + pr_number: '${{ steps.get_pr_number.outputs.pr_number }}' + steps: + - uses: 8BitJonny/gh-get-current-pr@2.1.1 + id: PR + - run: echo "Your PR number is ${{ steps.PR.outputs.number }} and its JSON is ${{ steps.PR.outputs.pr }}" + + - name: Get PR number + shell: sh + run: echo "${{ steps.PR.outputs.number }}" + + - name: Get PR number + shell: sh + id: get_pr_number + run: | + echo "::set-output name=pr_number::${{ steps.PR.outputs.number }}" + notify_failure: + runs-on: ubuntu-latest + needs: ["prepare_jobs"] + env: + PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} + steps: + - uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0 + - name: Get PR number + shell: sh + run: | + echo "${{ env.PR_NUMBER }}" + - name: Label + uses: ./.github/actions/fork-result-label + continue-on-error: true + with: + SUCCESS: 'false' + PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }} + + notify_success: + runs-on: ubuntu-latest + needs: ["prepare_jobs"] + env: + PR_NUMBER: ${{ needs.prepare_jobs.outputs.pr_number }} + steps: + - uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # v3.0.0 + - name: Get PR number + shell: sh + run: | + echo "${{ env.PR_NUMBER }}" + - name: Label + uses: ./.github/actions/fork-result-label + continue-on-error: true + with: + SUCCESS: 'true' + PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }} diff --git a/.github/workflows/test-deploy-fork.yml b/.github/workflows/test-deploy-fork.yml index 5031e003cd..2e93c58ad2 100644 --- a/.github/workflows/test-deploy-fork.yml +++ b/.github/workflows/test-deploy-fork.yml @@ -275,6 +275,13 @@ jobs: ❌ CI run has failed! Please see logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + - name: Label + uses: ./.github/actions/fork-result-label + continue-on-error: true + with: + SUCCESS: 'false' + PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }} + notify_success: runs-on: ubuntu-latest if: success() @@ -296,3 +303,10 @@ jobs: COMMENT_BODY: | ✅ CI run has succeded! You can find tests and deployment logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' + + - name: Label + uses: ./.github/actions/fork-result-label + continue-on-error: true + with: + SUCCESS: 'true' + PULL_REQUEST_NUMBER: ${{ env.PR_NUMBER }}