-
Notifications
You must be signed in to change notification settings - Fork 84
114 lines (113 loc) · 4.16 KB
/
autoupdate-spec.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
name: Update API Commands
on:
schedule:
- cron: 30 8 * * TUE
workflow_dispatch:
jobs:
update-api:
runs-on: ubuntu-latest
steps:
- uses: GitHubSecurityLab/actions-permissions/monitor@v1
with:
config: ${{ vars.PERMISSIONS_CONFIG }}
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install npm dependencies
run: npm install
- run: make update-openapi-spec
- name: Verify Changed files
run: |
FILES_CHANGED=false
if git diff --name-only | grep -qE '^tools/internal/specs/spec\.yaml'; then
FILES_CHANGED=true
fi
echo "FILES_CHANGED=${FILES_CHANGED}" >> "$GITHUB_ENV"
- run: make gen-api-commands
if: env.FILES_CHANGED == 'true'
- run: make gen-docs
if: env.FILES_CHANGED == 'true'
- name: Find JIRA ticket
id: find
if: env.FILES_CHANGED == 'true'
uses: mongodb/apix-action/find-jira@95298ca9c5b2dffcdf79efaae59b9d2d1ac245e2
with:
token: ${{ secrets.JIRA_API_TOKEN }}
jql: project = CLOUDP AND status NOT IN (Closed, Resolved) AND summary ~ "Update Autogenerated Commands"
- name: Set JIRA ticket (find)
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'true')
run: |
echo "JIRA_KEY=${{steps.find.outputs.issue-key}}" >> "$GITHUB_ENV"
- name: Create JIRA ticket
uses: mongodb/apix-action/create-jira@95298ca9c5b2dffcdf79efaae59b9d2d1ac245e2
id: create
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'false')
with:
token: ${{ secrets.JIRA_API_TOKEN }}
project-key: CLOUDP
summary: "[AtlasCLI] Update Autogenerated Commands"
issuetype: Story
description: Update Autogenerated Commands
components: AtlasCLI
assignee: ${{ secrets.ASSIGNEE_JIRA_TICKET }}
extra-data: |
{
"fields": {
"fixVersions": [
{
"id": "41805"
}
],
"customfield_12751": [
{
"id": "22223"
}
],
"customfield_10257": {
"id": "11861"
}
}
}
- name: Set JIRA ticket (create)
if: (env.FILES_CHANGED == 'true') && (steps.find.outputs.found == 'false')
run: |
echo "JIRA_KEY=${{steps.create.outputs.issue-key}}" >> "$GITHUB_ENV"
- name: set Apix Bot token
if: env.FILES_CHANGED == 'true'
id: app-token
uses: mongodb/apix-action/token@95298ca9c5b2dffcdf79efaae59b9d2d1ac245e2
with:
app-id: ${{ secrets.APIXBOT_APP_ID }}
private-key: ${{ secrets.APIXBOT_APP_PEM }}
- uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e
id: pr
if: env.FILES_CHANGED == 'true'
with:
token: ${{ steps.app-token.outputs.token }}
committer: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>"
author: "${{ steps.app-token.outputs.user-name }} <${{ steps.app-token.outputs.user-email }}>"
title: "${{ env.JIRA_KEY }}: Update Autogenerated Commands"
commit-message: "${{ env.JIRA_KEY }}: Update Autogenerated Commands"
delete-branch: true
base: master
branch: ${{ env.JIRA_KEY }}
labels: |
dependencies
go
auto_close_jira
body: |
## Proposed changes
Update Autogenerated Commands
_Jira ticket:_ ${{ env.JIRA_KEY }}
Note: Jira ticket will be closed automatically when this PR is merged.
- name: Set auto merge
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
gh pr merge "${{ steps.pr.outputs.pull-request-url }}" --auto --squash