Skip to content

Commit 35c23ab

Browse files
CLOUDP-319582: Run gen-purl as part of dependabot workflow (#3907)
Co-authored-by: apix-bot[bot] <168195273+apix-bot[bot]@users.noreply.github.com>
1 parent e6e6fbf commit 35c23ab

File tree

3 files changed

+136
-89
lines changed

3 files changed

+136
-89
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Create JIRA ticket for dependabot prs
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
repository-projects: read
11+
jobs:
12+
jira_task:
13+
name: Create Jira issue
14+
runs-on: ubuntu-latest
15+
if: github.actor == 'dependabot[bot]'
16+
steps:
17+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
18+
with:
19+
config: ${{ vars.PERMISSIONS_CONFIG }}
20+
- name: Checkout code
21+
uses: actions/[email protected]
22+
with:
23+
fetch-depth: 2
24+
- name: set Apix Bot token
25+
id: app-token
26+
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42
27+
with:
28+
app-id: ${{ secrets.APIXBOT_APP_ID }}
29+
private-key: ${{ secrets.APIXBOT_APP_PEM }}
30+
- name: Find JIRA team
31+
id: find
32+
run: |
33+
# shellcheck disable=SC2016 # intended use of single quotes
34+
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)"
35+
if [[ ("$GH_TEAM" == "") || ("$GH_TEAM" == "null") ]]; then
36+
GH_TEAM="apix-2"
37+
fi
38+
echo "GH_TEAM=$GH_TEAM"
39+
JIRA_TEAM="$(jq -r --arg i "$GH_TEAM" '.[$i]' < build/ci/library_owners_jira.json)"
40+
echo "JIRA_TEAM=$JIRA_TEAM"
41+
echo "assigned_team=$JIRA_TEAM" >> "${GITHUB_OUTPUT}"
42+
- name: Create JIRA ticket
43+
uses: mongodb/apix-action/create-jira@v8
44+
id: create
45+
with:
46+
token: ${{ secrets.JIRA_API_TOKEN }}
47+
project-key: CLOUDP
48+
summary: AtlasCLI Dependency Update n. ${{ github.event.pull_request.number }}
49+
issuetype: Story
50+
description: "This ticket tracks the following GitHub pull request: ${{ github.event.pull_request.html_url }}."
51+
components: AtlasCLI
52+
assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
53+
extra-data: |
54+
{
55+
"fields": {
56+
"fixVersions": [
57+
{
58+
"id": "41805"
59+
}
60+
],
61+
"customfield_12751": [
62+
{
63+
"id": "${{ steps.find.outputs.assigned_team }}"
64+
}
65+
],
66+
"customfield_10257": {
67+
"id": "11861"
68+
}
69+
}
70+
}
71+
- name: Add comment
72+
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043
73+
with:
74+
issue-number: ${{ github.event.pull_request.number }}
75+
body: |
76+
The ticket [${{ steps.create.outputs.issue-key }}](https://jira.mongodb.org/browse/${{ steps.create.outputs.issue-key }}) was created for internal tracking.
77+
78+
Note: Jira ticket will be closed automatically when this PR is merged.
79+
- name: Add auto_close_jira label
80+
env:
81+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
run: |
83+
gh pr edit "${{github.event.pull_request.html_url}}" --add-label "auto_close_jira"
84+
- name: Set auto merge
85+
env:
86+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
87+
run: |
88+
gh pr merge "${{ github.event.pull_request.html_url }}" --auto --squash
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Update PURLs list for dependabot prs
2+
3+
on:
4+
pull_request
5+
6+
permissions:
7+
pull-requests: write
8+
contents: write
9+
repository-projects: read
10+
jobs:
11+
update-purls:
12+
name: Update PURLs
13+
runs-on: ubuntu-latest
14+
if: github.actor == 'dependabot[bot]'
15+
steps:
16+
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
17+
with:
18+
config: ${{ vars.PERMISSIONS_CONFIG }}
19+
- name: Set Apix Bot token
20+
id: app-token
21+
uses: mongodb/apix-action/token@3024080388613583e3bd119bfb1ab4b4dbf43c42
22+
with:
23+
app-id: ${{ secrets.APIXBOT_APP_ID }}
24+
private-key: ${{ secrets.APIXBOT_APP_PEM }}
25+
- name: Checkout code
26+
uses: actions/[email protected]
27+
with:
28+
ref: ${{ github.head_ref }}
29+
token: ${{ steps.app-token.outputs.token }}
30+
fetch-depth: 0
31+
- uses: actions/setup-go@v5
32+
with:
33+
go-version-file: 'go.mod'
34+
- run: make gen-purls
35+
- name: Commit updated purls.txt if changed
36+
env:
37+
BRANCH_NAME: ${{ github.head_ref }}
38+
run: |
39+
echo "Changes to purls.txt:"
40+
if git diff --exit-code build/package/purls.txt; then
41+
echo "No changes to purls.txt"
42+
else
43+
git config --global user.name "${{ steps.app-token.outputs.user-name }}"
44+
git config --global user.email "${{ steps.app-token.outputs.user-email }}"
45+
git add build/package/purls.txt
46+
git commit -m "chore: update purls.txt"
47+
git push origin "$BRANCH_NAME"
48+
fi

.github/workflows/dependabot.yml

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)