Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TBM-413] refactor: get branch name in separate step #25

Merged
merged 4 commits into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions jira-issue-required/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ runs:
echo "POSSIBLE_ISSUE_REFERENCE=${{ inputs.possible_issue_reference }}" >> "$GITHUB_ENV"
echo "ISSUE_KEY_FOUND=0" >> "$GITHUB_ENV"
echo "PREFIX_TO_IGNORE_FOUND=0" >> "$GITHUB_ENV"
echo "BRANCH_NAME=0" >> "$GITHUB_ENV"

- name: Get Possible Issue Reference - Default / Push Event in PR
if: env.POSSIBLE_ISSUE_REFERENCE == '' && github.event_name == 'push' && github.event.pull_request != null
Expand All @@ -59,6 +60,15 @@ runs:
shell: bash
run: echo "POSSIBLE_ISSUE_REFERENCE=${{ github.head_ref }} ${{ github.event.pull_request.title }}" >> "$GITHUB_ENV"

- name: Get Branch name for Hotfix/Revert exceptions
shell: bash
run: |
if [[ -n "${{ github.event.pull_request.head.ref }}" ]]; then
echo "BRANCH_NAME=${{ github.event.pull_request.head.ref }}" >> "$GITHUB_ENV"
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> "$GITHUB_ENV"
fi

- name: Check if issue key exists
env:
JIRA_BASE_URL: ${{ inputs.jira_base_url }}
Expand All @@ -67,22 +77,23 @@ runs:
JIRA_STATUS_ALLOWED_TO_MERGE: ${{ inputs.JIRA_STATUS_ALLOWED_TO_MERGE }}
DEFAULT_HOTFIX_PREFIX: ${{ inputs.default_hotfix_prefix }}
DEFAULT_REVERT_PREFIX: ${{ inputs.default_revert_prefix }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
shell: bash
run: |
ISSUE_KEY=$(echo "$POSSIBLE_ISSUE_REFERENCE" | grep -oE '[a-zA-Z0-9]{1,10}-[0-9]+' | head -n 1)
echo "ISSUE_KEY=$ISSUE_KEY" >> "$GITHUB_ENV"

echo "DEFAULT_HOTFIX_PREFIX [$DEFAULT_HOTFIX_PREFIX]"
echo "DEFAULT_REVERT_PREFIX [$DEFAULT_REVERT_PREFIX]"
echo "Branch name ${{ github.event.pull_request.head.ref }}"
echo "BRANCH_NAME [$BRANCH_NAME]"

if [[ "${{ github.event.pull_request.head.ref }}" == "${{ env.DEFAULT_HOTFIX_PREFIX }}"* ]]; then
if [[ "${{ env.BRANCH_NAME }}" == "${{ env.DEFAULT_HOTFIX_PREFIX }}"* ]]; then
echo "PREFIX_TO_IGNORE_FOUND=1" >> "$GITHUB_ENV"
echo "Hotfix branch detected, skipping Jira issue status check."
exit 0
fi

if [[ "${{ github.event.pull_request.head.ref }}" == "${{ env.DEFAULT_REVERT_PREFIX }}"* ]]; then
if [[ "${{ env.BRANCH_NAME }}" == "${{ env.DEFAULT_REVERT_PREFIX }}"* ]]; then
echo "PREFIX_TO_IGNORE_FOUND=1" >> "$GITHUB_ENV"
echo "Revert branch detected, skipping Jira issue status check."
exit 0
Expand Down Expand Up @@ -111,6 +122,7 @@ runs:
JIRA_STATUS_ALLOWED_TO_MERGE: ${{ inputs.JIRA_STATUS_ALLOWED_TO_MERGE }}
DEFAULT_HOTFIX_PREFIX: ${{ inputs.default_hotfix_prefix }}
DEFAULT_REVERT_PREFIX: ${{ inputs.default_revert_prefix }}
BRANCH_NAME: ${{ env.BRANCH_NAME }}
shell: bash
run: |
ISSUE_KEY=$(echo "$POSSIBLE_ISSUE_REFERENCE" | grep -oE '[a-zA-Z0-9]{1,10}-[0-9]+' | head -n 1)
Expand All @@ -119,15 +131,15 @@ runs:

echo "DEFAULT_HOTFIX_PREFIX [$DEFAULT_HOTFIX_PREFIX]"
echo "DEFAULT_REVERT_PREFIX [$DEFAULT_REVERT_PREFIX]"
echo "Branch name ${{ github.head_ref }}"
echo "BRANCH_NAME [$BRANCH_NAME]"

if [[ "${{ github.head_ref }}" == "${{ env.DEFAULT_HOTFIX_PREFIX }}"* ]]; then
if [[ "${{ env.BRANCH_NAME }}" == "${{ env.DEFAULT_HOTFIX_PREFIX }}"* ]]; then
echo "PREFIX_TO_IGNORE_FOUND=1" >> "$GITHUB_ENV"
echo "Hotfix branch detected, skipping Jira issue status check."
exit 0
fi

if [[ "${{ github.head_ref }}" == "${{ env.DEFAULT_REVERT_PREFIX }}"* ]]; then
if [[ "${{ env.BRANCH_NAME }}" == "${{ env.DEFAULT_REVERT_PREFIX }}"* ]]; then
echo "PREFIX_TO_IGNORE_FOUND=1" >> "$GITHUB_ENV"
echo "Revert branch detected, skipping Jira issue status check."
exit 0
Expand Down