-
Notifications
You must be signed in to change notification settings - Fork 269
fix: update schema workflow to use comment-based approach for PRs #2248
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 13 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
17d966e
fix: update schema workflow to use comment-based approach for PRs
simaarfania d81e49e
test: add small change to trigger workflow
simaarfania 6e2882a
fix: use proper GitHub Actions bot email format
simaarfania 3efa58d
feat: add commands to regenerate schema
simaarfania b92586e
fix: failing workflow
simaarfania 545ba2c
fix: zizmor
simaarfania 76bc2ec
fix: hash
simaarfania 6debcc5
fix: model workflow off existing workflows
simaarfania f4d38fb
fix: remove README
simaarfania 844b7f9
fix: block merge if schema is inconsistent
simaarfania ca6de46
test: modify schema to be out to sync
simaarfania 962e9e0
fix: trigger workflow
simaarfania d62becd
fix: update schema
simaarfania ed1ac54
fix: address comment
simaarfania File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,95 @@ | ||
name: update provider schema | ||
name: enforce schema consistency | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- 'internal/**' | ||
- 'pkg/**' | ||
- 'go.mod' | ||
- 'go.sum' | ||
workflow_dispatch: {} | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
update-schema: | ||
name: update provider schema | ||
enforce-schema-consistency: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: write | ||
contents: read | ||
steps: | ||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
- uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | ||
- name: Checkout | ||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@f111f3307d8850f501ac008e886eec1fd1932a34 # v5.3.0 | ||
with: | ||
go-version-file: go.mod | ||
- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | ||
|
||
- name: build provider | ||
run: go build . | ||
- name: Set up Terraform | ||
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2 | ||
|
||
- name: Generate current schema | ||
run: | | ||
go build . | ||
./scripts/generate_schema.sh > current_schema.json | ||
|
||
- name: Check for schema changes | ||
id: schema-check | ||
run: | | ||
# Compare with committed schema if it exists | ||
if [ -f "provider_schema.json" ]; then | ||
if ! diff -q provider_schema.json current_schema.json > /dev/null; then | ||
echo "schema_changed=true" >> $GITHUB_OUTPUT | ||
echo "Schema changes detected!" | ||
else | ||
echo "schema_changed=false" >> $GITHUB_OUTPUT | ||
echo "No schema changes detected." | ||
fi | ||
else | ||
echo "schema_changed=true" >> $GITHUB_OUTPUT | ||
echo "No existing schema file found." | ||
fi | ||
|
||
- name: Update templates | ||
if: steps.schema-check.outputs.schema_changed == 'true' | ||
run: | | ||
go run scripts/generate_issue_template.go --update-schema | ||
|
||
- name: Comment on PR | ||
if: steps.schema-check.outputs.schema_changed == 'true' | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const comment = `## 🔧 Schema Update Required | ||
|
||
This PR introduces changes that affect the Terraform provider schema. The issue templates need to be updated. | ||
|
||
### 📋 Required Action | ||
|
||
Please run the generator to update templates: | ||
|
||
\`\`\`bash | ||
make generate-templates | ||
\`\`\` | ||
|
||
Then commit the updated files: | ||
- \`provider_schema.json\` | ||
- \`.github/ISSUE_TEMPLATE/3-bug-report-enhanced.yml\` | ||
|
||
--- | ||
*This comment was generated automatically because schema changes were detected.*`; | ||
|
||
- name: update schema and generate template | ||
run: go run scripts/generate_issue_template.go --update-schema | ||
github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: comment | ||
}); | ||
|
||
- name: commit changes | ||
- name: Fail if schema changes detected | ||
if: steps.schema-check.outputs.schema_changed == 'true' | ||
run: | | ||
git config user.name "github-actions[bot]" | ||
git config user.email "github-actions[bot]@users.noreply.github.com" | ||
git add provider_schema.json .github/ISSUE_TEMPLATE/3-bug-report-enhanced.yml | ||
git diff --cached --quiet || git commit -m "chore: update provider schema and issue template" | ||
git push | ||
echo "❌ Schema changes detected - blocking merge until templates are updated" | ||
echo "Run: make generate-templates" | ||
echo "Then commit the updated files" | ||
exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.