Skip to content
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
53 changes: 53 additions & 0 deletions .github/workflows/dependabot2jira.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Dependabot Jira ticket
# This workflow is triggered to create a Jira ticket for every new dependabot PR

permissions: {}

on:
pull_request:
types: [opened]

jobs:
run-if-dependabot:
if: github.actor == 'dependabot'
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Create a new Jira ticket
env:
JIRA_PROJECT_KEY: "DAOS"
PR_TITLE: ${{ github.event.pull_request.title }}
PR_BODY: ${{ github.event.pull_request.body }}
run: |
new_title=$(echo "$PR_TITLE" | sed 's/^Doc-only: true //')
jira_response=$(curl -u "${{ secrets.JIRA_EMAIL }}:${{ secrets.JIRA_API_TOKEN }}" \
-X POST \
-H "Content-Type: application/json" \
--data "$(jq -n --arg title "$new_title" \
--arg body "$PR_BODY" \
--arg project_key "$JIRA_PROJECT_KEY" \
'{
fields: {
project: { key: $project_key },
summary: $title,
description: $body,
issuetype: { name: "Story" }
}
}')" ${{ secrets.JIRA_BASE_URL }}
)

jira_ticket_key=$(echo $jira_response | jq -r .key)
echo "PR_NEW_TITLE=$jira_ticket_key cq: $new_title" >> $GITHUB_ENV

- name: Update the PR title with a prefix based on the Jira ticket key
env:
PR_URL: "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" # yamllint disable-line
run: |
curl -X PATCH -sS -o /dev/null \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/json" \
--data "$(jq -n --arg title "$PR_NEW_TITLE" \
'{
title: $title,
}' )" $PR_URL
Loading