1+ name : Update GraphQL Schema
2+
3+ on :
4+ pull_request :
5+ branches : [ "main" ]
6+ types : [opened, synchronize, reopened]
7+
8+ jobs :
9+ update-schema :
10+ runs-on : ubuntu-latest
11+ permissions :
12+ contents : write
13+ pull-requests : write
14+
15+ steps :
16+ - name : Checkout repository
17+ uses : actions/checkout@v4
18+ with :
19+ token : ${{ secrets.GITHUB_TOKEN }}
20+ ref : ${{ github.head_ref }}
21+
22+ - name : Download latest schema
23+ run : |
24+ curl -s https://hackerone.com/schema.graphql -o /tmp/new_schema.graphql
25+
26+ - name : Check if schema has changed
27+ id : check_changes
28+ run : |
29+ if ! cmp -s /tmp/new_schema.graphql graphql/schema.graphql; then
30+ echo "schema_changed=true" >> $GITHUB_OUTPUT
31+ echo "Schema has changed"
32+ else
33+ echo "schema_changed=false" >> $GITHUB_OUTPUT
34+ echo "Schema is up to date"
35+ fi
36+
37+ - name : Update schema file
38+ if : steps.check_changes.outputs.schema_changed == 'true'
39+ run : |
40+ cp /tmp/new_schema.graphql graphql/schema.graphql
41+
42+ - name : Commit changes
43+ if : steps.check_changes.outputs.schema_changed == 'true'
44+ run : |
45+ git config --local user.email "[email protected] " 46+ git config --local user.name "GitHub Action"
47+ git add graphql/schema.graphql
48+ git commit -m "Update GraphQL schema from HackerOne"
49+ git push
50+
51+ - name : Comment on PR
52+ if : steps.check_changes.outputs.schema_changed == 'true'
53+ uses : actions/github-script@v7
54+ with :
55+ script : |
56+ github.rest.issues.createComment({
57+ issue_number: context.issue.number,
58+ owner: context.repo.owner,
59+ repo: context.repo.repo,
60+ body: '🔄 **GraphQL Schema Updated**\n\nThe GraphQL schema has been automatically updated from HackerOne\'s latest schema. Please review the changes before merging.'
61+ })
62+
63+ - name : Skip comment if no changes
64+ if : steps.check_changes.outputs.schema_changed == 'false'
65+ run : echo "No schema changes detected, skipping update"
0 commit comments