Skip to content

DAOS-18533 ddb: Fix ddb completion #609

DAOS-18533 ddb: Fix ddb completion

DAOS-18533 ddb: Fix ddb completion #609

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: startsWith(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: {
type: "doc",
version: 1,
content: [
{
type: "paragraph",
content: [
{
type: "text",
text: $body
}
]
}
]
},
issuetype: { name: "Story" }
}
}')" ${{ secrets.JIRA_ISSUES_REST_API_V3_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