-
Notifications
You must be signed in to change notification settings - Fork 95
167 lines (155 loc) · 5.57 KB
/
graphql-schema.yml
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: NerdGraph Schema Diff
on:
workflow_dispatch:
schedule:
# Cron executes at 0800, 1200, 1600 UTC (8am, 12pm, 4pm)
# Monday through Friday
- cron: "0 8,12,16 * * 1-5"
jobs:
checkForApiUpdates:
name: Check for API updates
runs-on: ubuntu-latest
outputs:
heroMention: ${{ steps.schema-diff.outputs.hero_mention }}
tutoneConfig: ${{ steps.schema-diff.outputs.tutone_config }}
newMutations: ${{ steps.schema-diff.outputs.new_api_mutations }}
packages: ${{ steps.schema-diff.outputs.packages }}
steps:
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Go
uses: actions/setup-go@v5
with:
go-version: 1.22.x
- name: Checkout code
uses: actions/checkout@v4
- name: Install deps
run: ls scripts && npm install yaml lodash.merge
- name: Download artifact
uses: actions/github-script@v7
env:
WORKFLOW_FILENAME: graphql-schema.yml
ARTIFACT_NAME: schema
ARTIFACT_FILENAME: schema.zip
UNZIP_DIR: ./
with:
script: |
const script = require('./scripts/download-previous-artifact.js')
await script({github, context, core})
- name: Rename schema.json to schema-old.json
run: |
find ./ -type f -name "schema.json"
mv schema.json schema-old.json
- name: Fetch GraphQL Schema
env:
NEW_RELIC_API_KEY: ${{ secrets.NEW_RELIC_API_KEY }}
run: |
go install github.com/newrelic/tutone/cmd/tutone@latest
tutone fetch --refetch
ls
- name: Check for schema updates
id: schema-diff
uses: actions/github-script@v7
with:
script: |
const script = require('./scripts/schema-diff-reporter.js')
await script({core})
- name: Send report to Slack
id: slack
uses: slackapi/slack-github-action@v1.26
with:
# Uses Slack's Block Kit to build the message
# https://app.slack.com/block-kit-builder
payload: |
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":mag_right: *New Relic Client Go | NerdGraph API Report*"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*API Mutations Count:* ${{ steps.schema-diff.outputs.total_api_mutations_count }}\n*Client Mutations Count:* ${{ steps.schema-diff.outputs.client_mutations_count }}\n*Client Mutations Missing Count:* ${{ steps.schema-diff.outputs.client_mutations_missing_count }}\n"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*New API Mutations*"
}
},
{
"type": "context",
"elements": [
{
"type": "plain_text",
"text": ${{ toJSON(steps.schema-diff.outputs.new_api_mutations) }}
}
]
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "More information can be viewed in the job summary. ${{ steps.schema-diff.outputs.hero_mention }}"
},
"accessory": {
"type": "button",
"text": {
"type": "plain_text",
"text": "Job Summary",
"emoji": true
},
"value": "View Job Summary",
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
"action_id": "button-action"
}
},
{
"type": "divider"
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "\n\n"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
# After reporting changes to the schema, upload the most
# recent version so we can compare on the next run.
- name: Upload latest schema.json
uses: actions/upload-artifact@v4
with:
# Duration after which artifact will expire in days. 0 means using default retention.
# Minimum 1 day.
# Maximum 90 days unless changed from the repository settings page.
retention-days: 90
name: schema
path: schema.json
if-no-files-found: error
overwrite: true
generate-code:
if: needs.checkForApiUpdates.outputs.heroHention != ''
needs: checkForApiUpdates
uses: newrelic/newrelic-client-go/.github/workflows/generate.yml@feat/automated-codegen
with:
tutoneConfig: ${{ needs.checkForApiUpdates.outputs.tutoneConfig }}
packages: ${{ needs.checkForApiUpdates.outputs.packages }}
newMutations: ${{ needs.checkForApiUpdates.outputs.newMutations }}
secrets: inherit