File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Dependabot Jira ticket
2+ # This workflow is triggered to create a Jira ticket for every new dependabot PR
3+
4+ permissions : {}
5+
6+ on :
7+ pull_request :
8+ types : [opened]
9+
10+ jobs :
11+ run-if-dependabot :
12+ if : github.actor == 'dependabot'
13+ runs-on : ubuntu-latest
14+ permissions :
15+ pull-requests : write
16+ steps :
17+ - name : Create a new Jira ticket
18+ env :
19+ JIRA_PROJECT_KEY : " DAOS"
20+ PR_TITLE : ${{ github.event.pull_request.title }}
21+ PR_BODY : ${{ github.event.pull_request.body }}
22+ run : |
23+ new_title=$(echo "$PR_TITLE" | sed 's/^Doc-only: true //')
24+ jira_response=$(curl -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
25+ -X POST \
26+ -H "Content-Type: application/json" \
27+ --data "$(jq -n --arg title "$new_title" \
28+ --arg body "$PR_BODY" \
29+ --arg project_key "$JIRA_PROJECT_KEY" \
30+ '{
31+ fields: {
32+ project: { key: $project_key },
33+ summary: $title,
34+ description: $body,
35+ issuetype: { name: "Story" }
36+ }
37+ }')" ${{ secrets.JIRA_BASE_URL }}
38+ )
39+
40+ jira_ticket_key=$(echo $jira_response | jq -r .key)
41+ echo "PR_NEW_TITLE=$jira_ticket_key cq: $new_title" >> $GITHUB_ENV
42+
43+ - name : Update the PR title with a prefix based on the Jira ticket key
44+ env :
45+ PR_URL : " https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" # yamllint disable-line
46+ run : |
47+ curl -X PATCH -sS -o /dev/null \
48+ -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
49+ -H "Content-Type: application/json" \
50+ --data "$(jq -n --arg title "$PR_NEW_TITLE" \
51+ '{
52+ title: $title,
53+ }' )" $PR_URL
You can’t perform that action at this time.
0 commit comments