-
-
Notifications
You must be signed in to change notification settings - Fork 5
141 lines (122 loc) · 3.8 KB
/
Copy pathgraphql-schema-sync.yml
File metadata and controls
141 lines (122 loc) · 3.8 KB
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
name: GraphQL Schema Sync
on:
workflow_dispatch:
inputs:
target:
description: Schema target to refresh
required: true
default: both
type: choice
options:
- anilist
- anitrend
- both
repository_dispatch:
types: [graphql-schema-sync]
# schedule:
# - cron: '0 6 * * 1'
permissions:
contents: read
concurrency:
group: graphql-schema-sync
cancel-in-progress: false
jobs:
sync-schemas:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/create-github-app-token@v3
id: app-token
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout repository
uses: actions/checkout@v7
with:
ref: develop
token: ${{ steps.app-token.outputs.token }}
persist-credentials: false
- name: Setup Node.js
uses: actions/setup-node@v6
with:
node-version: 24
- name: Normalize target
id: target
env:
DISPATCH_TARGET: ${{ inputs.target }}
PAYLOAD_TARGET: ${{ github.event.client_payload.target }}
EVENT_NAME: ${{ github.event_name }}
run: |
case "$EVENT_NAME" in
workflow_dispatch)
target="$DISPATCH_TARGET"
;;
repository_dispatch)
target="$PAYLOAD_TARGET"
;;
schedule)
target="both"
;;
*)
printf 'Unsupported event: %s\n' "$EVENT_NAME" >&2
exit 1
;;
esac
case "$target" in
anilist|anitrend|both)
printf 'target=%s\n' "$target" >> "$GITHUB_OUTPUT"
;;
*)
printf 'Invalid target: %s\n' "$target" >&2
exit 1
;;
esac
- name: Refresh GraphQL schemas
run: bash .github/scripts/sync-graphql-schemas.sh "${{ steps.target.outputs.target }}"
- name: Collect changed schema files
id: changed-files
run: |
files=$(git diff --name-only -- data/schema.graphql data/anitrend.schema.graphql)
if [ -n "$files" ]; then
{
printf 'markdown<<EOF\n'
for file in $files; do
printf -- '- `%s`\n' "$file"
done
printf 'EOF\n'
} >> "$GITHUB_OUTPUT"
else
{
printf 'markdown<<EOF\n'
printf -- '- (no schema file changes detected)\n'
printf 'EOF\n'
} >> "$GITHUB_OUTPUT"
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v8
with:
token: ${{ steps.app-token.outputs.token }}
signoff: true
delete-branch: true
commit-message: "ci(graphql): refresh GraphQL schemas"
title: "ci(graphql): refresh GraphQL schemas"
body: |
## Description
Automated GraphQL schema refresh for `${{ steps.target.outputs.target }}`.
- Trigger event: `${{ github.event_name }}`
- Updated files:
${{ steps.changed-files.outputs.markdown }}
## Screenshots:
N/A (schema-only update)
## Types of changes
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [x] Enhancement (Improves existing functionality)
branch: ci/update-graphql-schemas
base: develop
labels: ":skateboard: skip-changelog"
add-paths: |
data/schema.graphql
data/anitrend.schema.graphql