-
Notifications
You must be signed in to change notification settings - Fork 0
37 lines (31 loc) · 1.32 KB
/
new1.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
name: Check Branch Name and Verify JIRA ID on JIRA Board
on: [push]
jobs:
run-script:
runs-on: ubuntu-latest
steps:
- name: Run If Else Script
run: |
if [[ "${{ github.event_name }}" == "push" ]]; then
echo "Event was a push"
else
echo "Event was not a push"
fi
- name: Check Branch Name
id: check-branch
run: |
branch_name="${GITHUB_REF#refs/heads/}"
if [[ $branch_name =~ [A-Z]{2,5}-[0-9]+ ]]; then
echo "Branch name contains a JIRA ID: $branch_name"
echo "::set-output name=jira_id::$branch_name"
else
echo "Branch name does not contain a JIRA ID: $branch_name"
exit 1
fi
- name: Verify JIRA ID on JIRA Board
id: verify-jira-id
run: |
jira_id="${{ steps.check-branch.outputs.jira_id }}"
jira_url="https://your-jira-instance.atlassian.net/rest/api/2/issue/$jira_id"
# Replace 'your-jira-username' and 'your-jira-api-token' with your Jira credentials
curl -u your-jira-username:your-jira-api-token -X GET -H "Content-Type: application/json" $jira_url | grep -q 'id' && echo "JIRA ID $jira_id exists on the JIRA board" || (echo "JIRA ID $jira_id does not exist on the JIRA board" && exit 1)