diff --git a/workflow-templates/enforce-jira-issue-key.properties.json b/workflow-templates/enforce-jira-issue-key.properties.json new file mode 100644 index 0000000..7b5a990 --- /dev/null +++ b/workflow-templates/enforce-jira-issue-key.properties.json @@ -0,0 +1,5 @@ +{ + "name": "Enforce Jira issue workflow", + "description": "A workflow that enforce to have a Jira issue key in the branch name or PR name when creating a PR.", + "iconName": "workflow-icon" +} \ No newline at end of file diff --git a/workflow-templates/enforce-jira-issue-key.yml b/workflow-templates/enforce-jira-issue-key.yml new file mode 100644 index 0000000..86990a5 --- /dev/null +++ b/workflow-templates/enforce-jira-issue-key.yml @@ -0,0 +1,37 @@ +name: Ensure Jira issue is linked + +on: + pull_request: + types: [opened, edited, reopened, synchronize] + +jobs: + check_for_issue_key: + runs-on: ubuntu-latest + steps: + - name: Log into Jira + uses: atlassian/gajira-login@v2.0.0 + env: + JIRA_BASE_URL: ${{ secrets.TIP_JIRA_URL }} + JIRA_USER_EMAIL: ${{ secrets.TIP_JIRA_USER_EMAIL }} + JIRA_API_TOKEN: ${{ secrets.TIP_JIRA_API_TOKEN }} + - name: Find issue key in PR title + id: issue_key_pr_title + continue-on-error: true + uses: atlassian/gajira-find-issue-key@v2.0.2 + with: + string: ${{ github.event.pull_request.title }} + from: "" # required workaround for bug https://github.com/atlassian/gajira-find-issue-key/issues/24 + - name: Find issue key in branch name + continue-on-error: true + id: issue_key_branch_name + uses: atlassian/gajira-find-issue-key@v2.0.2 + with: + string: ${{ github.event.pull_request.head.ref }} + from: "" # required workaround for bug https://github.com/atlassian/gajira-find-issue-key/issues/24 + + - name: Check if issue key was found + run: | + if [[ -z "${{ steps.issue_key_pr_title.outputs.issue }}" && -z "${{ steps.issue_key_branch_name.outputs.issue }}" ]]; then + echo "Jira issue key could not be found!" + exit 1 + fi \ No newline at end of file diff --git a/workflow-templates/workflow-icon.svg b/workflow-templates/workflow-icon.svg new file mode 100644 index 0000000..b0f3a9d --- /dev/null +++ b/workflow-templates/workflow-icon.svg @@ -0,0 +1 @@ + \ No newline at end of file