[DEVOPS-578] Fix "API already exists" errors #258
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Run Jira Linter | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
workflow_call: | |
inputs: | |
fail-on-error: | |
type: string | |
description: A Boolean which, if set to true, fails the GitHub Action when an error occurs. Default true. | |
default: 'true' | |
skip-comments: | |
type: string | |
description: A Boolean if set to true then action-jira-linter will skip adding lint comments for PR title. | |
default: 'false' | |
secrets: | |
JIRA_TOKEN: | |
required: true | |
env: | |
githubPrBranch: ${{ github.head_ref }} | |
githubPrTitle: ${{ github.event.pull_request.title }} | |
jobs: | |
jira-lint: | |
name: Run Jira Lint | |
if: ${{ github.actor != 'amutechtest' && github.actor != 'dependabot[bot]' && !contains(github.head_ref, 'sync') && !contains(github.event.pull_request.labels.*.name, 'disable-jira-linter') }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retrieve Jira issue key from PR | |
id: jira-ticket | |
run: | | |
PR_BRANCH=$(echo "${{ env.githubPrBranch }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true) | |
PR_TITLE=$(echo "${{ env.githubPrTitle }}" | grep -Eio "\b[A-Z][A-Z0-9_]+-[1-9][0-9]*" || true) | |
for var in ${PR_BRANCH} ${PR_TITLE}; do JIRA_TICKET_ID=$(echo $var | grep -E ".") && break ; done | |
if [ -z "${JIRA_TICKET_ID}" ]; then | |
if [ "${{ inputs.fail-on-error }}" = "true" ]; then | |
echo "::error::A Jira issue key is missing from your branch name and pull request title. Please confirm it is linked properly in the pull request." | |
exit 1 | |
else | |
echo "::warning::A Jira issue key is missing from your branch name and pull request title. Please confirm it is linked properly in the pull request." | |
echo "ticket-found=false" >> $GITHUB_OUTPUT | |
fi | |
fi | |
- name: Check if missing Jira issue key comment exists | |
if: ${{ steps.jira-ticket.outputs.ticket-found != 'false' }} | |
id: comment | |
uses: peter-evans/find-comment@v3 | |
with: | |
issue-number: ${{ github.event.number }} | |
body-includes: A JIRA Issue ID is missing from your branch name! | |
direction: last | |
- uses: jira-tools/action-jira-linter@v1.0.1 | |
if: ${{ ! steps.comment.outputs.comment-body && steps.jira-ticket.outputs.ticket-found != 'false' }} | |
name: Jira Lint | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
jira-token: ${{ secrets.JIRA_TOKEN }} | |
jira-base-url: https://amuniversal.atlassian.net | |
pr-threshold: 1000 | |
jira-user: amu_deploy@amuniversal.com | |
validate-issue-status: true | |
allowed-issue-statuses: | | |
New | |
Reopened | |
To Do | |
In Progress | |
Peer Review | |
In Staging / QA | |
Ready for Staging | |
Ready For Staging | |
In Development Env | |
Approved | |
Resolved | |
skip-branches: "^(main|development|staging|production|dev)$" | |
fail-on-error: ${{ inputs.fail-on-error }} | |
skip-comments: ${{ inputs.skip-comments }} |