Skip to content

CLOUDP-279932: SDK based authentication #819

CLOUDP-279932: SDK based authentication

CLOUDP-279932: SDK based authentication #819

Workflow file for this run

---
name: Create JIRA ticket for dependabot prs
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
contents: read
jobs:
jira_task:
name: Create Jira issue
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
with:
config: ${{ vars.PERMISSIONS_CONFIG }}
- name: Checkout code
uses: actions/[email protected]
with:
fetch-depth: 2
- name: Find JIRA team
id: find
run: |
# shellcheck disable=SC2016 # intended use of single quotes
GH_TEAM="$(git diff HEAD~1..HEAD -- go.mod | grep -v '// indirect' | grep -i '^\-' | grep -v '^\-\-\-' | awk '{print $2}' | xargs -I $$ jq -r --arg i $$ '.[$i]' build/ci/library_owners.json | head -1)"
if [[ ("$GH_TEAM" == "") || ("$GH_TEAM" == "null") ]]; then
GH_TEAM="apix-2"
fi
echo "GH_TEAM=$GH_TEAM"
JIRA_TEAM="$(jq -r --arg i "$GH_TEAM" '.[$i]' < build/ci/library_owners_jira.json)"
echo "JIRA_TEAM=$JIRA_TEAM"
echo "assigned_team=$JIRA_TEAM" >> "${GITHUB_OUTPUT}"
- name: Create JIRA ticket
id: create
shell: bash
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_URL: ${{ github.event.pull_request.html_url }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
JIRA_ASSIGNEE: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
run: |
json_response=$(curl --request POST \
--url 'https://jira.mongodb.org/rest/api/2/issue' \
--header 'Authorization: Bearer '"${JIRA_API_TOKEN}" \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"fields": {
"project": {
"id": "10984"
},
"summary": "AtlasCLI Dependency Update n. '"${PR_NUMBER}"'",
"issuetype": {
"id": "12"
},
"customfield_12751": [{
"id": "${{ steps.find.outputs.assigned_team }}"
}],
"description": "This ticket tracks the following GitHub pull request: '"${PR_URL}"'.",
"components": [
{
"id": "30450"
}
],
"assignee": {
"name": "'"${JIRA_ASSIGNEE}"'"
}
}
}')
echo "Response: ${json_response}"
JIRA_TICKET_ID=$(echo "${json_response}" | jq -r '.key')
echo "The following JIRA ticket has been created: ${JIRA_TICKET_ID}"
echo "jira-ticket-id=${JIRA_TICKET_ID}" >> "${GITHUB_OUTPUT}"
- name: Add comment
uses: peter-evans/create-or-update-comment@v4
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
The ticket [${{ steps.create.outputs.jira-ticket-id }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.jira-ticket-id }}) was created for internal tracking.