diff --git a/.github/workflows/workflow-issue-status.yml b/.github/workflows/workflow-issue-status.yml index 7d604d41..62d28219 100644 --- a/.github/workflows/workflow-issue-status.yml +++ b/.github/workflows/workflow-issue-status.yml @@ -47,24 +47,30 @@ jobs: path: github-workflows - name: Extract issue number + env: + GITHUB_EVENT_NAME: ${{ github.event_name }} + GITHUB_EVENT_ACTION: ${{ github.event.action }} + GITHUB_ISSUE_NUMBER: ${{ github.event.issue.number }} + GITHUB_HEAD_REF: ${{ github.event.pull_request.head.ref }} run: | ISSUE_NUMBER="" - if [ "${{ github.event_name }}" == "issues" ] && [ "${{ github.event.action }}" == "opened" ]; then - ISSUE_NUMBER="${{ github.event.issue.number }}" - elif [ "${{ github.event_name }}" == "pull_request" ]; then - echo "test" - ISSUE_NUMBER=$(echo "${{ github.event.pull_request.head.ref }}" | grep -oE '^[0-9]+') + if [ "$GITHUB_EVENT_NAME" == "issues" ] && [ "$GITHUB_EVENT_ACTION" == "opened" ]; then + ISSUE_NUMBER="$GITHUB_ISSUE_NUMBER" + elif [ "$GITHUB_EVENT_NAME" == "pull_request" ]; then + BRANCH_NAME="$GITHUB_HEAD_REF" + if [[ "$BRANCH_NAME" =~ ^[0-9]{2,} ]]; then + ISSUE_NUMBER=$(echo "$BRANCH_NAME" | grep -oE '^[0-9]+') + else + echo "1. No issue found. The branch must be created from the issue page so that its name is in the correct format (e.g., 123-my-new-feature)." + echo "2. This pull request was generated by a bot (e.g., Renovate or Dependabot), so it is expected that there isn't an associated issue linked to the pull request branch." + exit 0 + fi fi - echo "test 2" - if [ -n "$ISSUE_NUMBER" ]; then echo "Issue number '$ISSUE_NUMBER'" echo "ISSUE_NUMBER=$ISSUE_NUMBER" >> $GITHUB_ENV - else - echo "1. No issue found. The branch must be created from the issue page so that its name is in the correct format (e.g., 123-my-new-feature)." - echo "2. This pull request was generated by a bot (e.g., Renovate or Dependabot), so it is expected that there isn't an associated issue linked to the pull request branch." fi - name: Fetch issue project(s) information(s)