diff --git a/.github/workflows/reusable-jira-pr_actions.yml b/.github/workflows/reusable-jira-pr_actions.yml index ae5333c..7be7cd5 100644 --- a/.github/workflows/reusable-jira-pr_actions.yml +++ b/.github/workflows/reusable-jira-pr_actions.yml @@ -28,7 +28,6 @@ permissions: jobs: get_issue_key: - if: ${{ github.event.pull_request.user.login != 'dependabot' && github.event.pullrequest.user.type != 'Bot' }} runs-on: ubuntu-latest timeout-minutes: 5 outputs: @@ -39,6 +38,7 @@ jobs: steps: - name: Find JIRA issue key from branch id: issue_key_from_branch + if: ${{ !startsWith(github.head_ref, 'dependabot/') && github.head_ref != 'pre-commit-ci-update-config' }} env: HEAD_REF: ${{ github.head_ref }} run: > @@ -80,9 +80,22 @@ jobs: echo "issue_key=$issue_key" >> $GITHUB_OUTPUT + - name: Fail if no Jira key and not expected bot PR + if: ${{ !steps.issue_key.outputs.issue_key && + !(github.event.sender.login == 'dependabot[bot]' && startsWith(github.head_ref, 'dependabot/github-actions/') && contains(github.head_ref, '/mirageo-ci-tools') && startsWith(github.event.pull_request.title, 'Bump ')) && + !(github.event.sender.login == 'pre-commit-ci[bot]' && github.head_ref == 'pre-commit-ci-update-config') }} + run: | + echo "::error::No Jira issue key found. Please include one in your PR title (e.g. ABC-123: your title)" + exit 1 + add_jira_summary: - if: ${{ github.event.action == 'opened' }} + if: ${{ needs.get_issue_key.result == 'success' && + !startsWith(github.event.pull_request.body, format('**{0}', needs.get_issue_key.outputs.issue_key)) && + (github.event.action == 'opened' || + (github.event.action == 'synchronize' && + github.event.pull_request.user.type == 'Bot' && + github.event.sender.type == 'User')) }} runs-on: ubuntu-latest timeout-minutes: 20 needs: get_issue_key @@ -128,6 +141,7 @@ jobs: > /dev/null check_jira_issue: + if: ${{ needs.get_issue_key.result == 'success' }} runs-on: ubuntu-latest timeout-minutes: 20 needs: get_issue_key