@@ -38,32 +38,32 @@ jobs:
3838 token : ${{secrets.GITHUB_TOKEN}}
3939 labels : changing-submodules-on-purpose
4040
41- # The next two steps are necessary to force the CI to be executed when a PR is opened by the github-bot.
41+ # The next step is necessary to force the CI to be executed when a PR is opened by the github-bot.
4242 # The PR event isn't triggered when the bot opens the PR and as such doesn't trigger the workflows that use the event as their trigger.
4343 # By closing and opening the PR, it forces the PR event to be triggered.
44- - name : Check if PR is already closed and reopened
45- id : check_pr
44+ - name : Check if PR is already closed and reopen if necessary
45+ id : check_and_reopen_pr
4646 run : |
4747 PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state open --head automation/update_main --json number --jq '.[0].number')
4848 if [ -z "$PR_NUMBER" ]; then
4949 echo "PR not found."
5050 exit 1
5151 fi
5252 LABELS=$(gh pr view $PR_NUMBER --repo ${{ github.repository }} --json labels --jq '.labels[].name')
53- if echo "$LABELS" | grep -q "sl-automation-triggered"; then
54- echo "pr_needs_reopen=true" >> $GITHUB_OUTPUT
53+ if ! echo "$LABELS" | grep -q "sl-automation-triggered"; then
54+ gh pr close $PR_NUMBER --repo ${{ github.repository }}
55+ gh pr reopen $PR_NUMBER --repo ${{ github.repository }}
56+ echo "pr_needs_label=true" >> $GITHUB_OUTPUT
5557 else
56- echo "pr_needs_reopen =false" >> $GITHUB_OUTPUT
58+ echo "pr_needs_label =false" >> $GITHUB_OUTPUT
5759 fi
5860 env :
5961 GITHUB_TOKEN : ${{secrets.WORKFLOW_TOKEN}}
6062
61- - name : Close and Reopen PR
62- if : ${{ steps.check_pr .outputs.pr_needs_reopen }}
63+ - name : Add label to PR
64+ if : ${{ steps.check_and_reopen_pr .outputs.pr_needs_label }}
6365 run : |
6466 PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --state open --head automation/update_main --json number --jq '.[0].number')
65- gh pr close $PR_NUMBER --repo ${{ github.repository }}
66- gh pr reopen $PR_NUMBER --repo ${{ github.repository }}
6767 gh pr edit $PR_NUMBER --add-label "sl-automation-triggered"
6868 env :
69- GITHUB_TOKEN : ${{secrets.WORKFLOW_TOKEN }}
69+ GITHUB_TOKEN : ${{secrets.GITHUB_TOKEN }}
0 commit comments