Skip to content

Bump github.com/openfga/openfga from 1.11.5 to 1.14.1 #478

Bump github.com/openfga/openfga from 1.11.5 to 1.14.1

Bump github.com/openfga/openfga from 1.11.5 to 1.14.1 #478

name: Check Generated Code
on:
pull_request:
branches: [ main ]
permissions:
pull-requests: write # Needed for commenting on PRs
contents: read # Needed for checking out code
jobs:
check-generated:
name: Check Generated Code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for git diff to work properly
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.26.0'
- name: Install protoc
run: |
sudo apt-get update
sudo apt-get install -y protobuf-compiler
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Run go generate
run: |
go generate ./...
- name: Check for changes
id: check_changes
run: |
# Create a temporary file for the diff, ignoring footer lines
# Also ignore BASE protoc version; DO CHECK protoc-gen-go, protoc-gen-go-grpc versions
git diff \
--ignore-matching-lines="Auto generated by spf13/cobra " \
--ignore-matching-lines="protoc " \
> changes.diff
# Check if there are any changes
if [ -s changes.diff ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: Comment on PR
uses: actions/github-script@v7
if: steps.check_changes.outputs.has_changes == 'true'
with:
script: |
// Find existing comment from this workflow
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('## Generated Code Changes Required')
);
// Read the diff file
const fs = require('fs');
const diff = fs.readFileSync('changes.diff', 'utf8');
// Limit diff to 50,000 characters (leaving room for the rest of the comment)
const MAX_DIFF_LENGTH = 50000;
const isTruncated = diff.length > MAX_DIFF_LENGTH;
const truncatedDiff = isTruncated ? diff.substring(0, MAX_DIFF_LENGTH) + '\n... (diff truncated)' : diff;
const body = '## Generated Code Changes Required\n\n' +
'The following files may need to be regenerated. Please run `go generate ./...` and commit the changes:\n\n' +
'```diff\n' +
truncatedDiff +
'\n```' +
(isTruncated ? '\n\n*Note: The diff has been truncated. Please run `go generate ./...` locally to see all changes.*' : '');
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body
});
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
- name: Update success comment
uses: actions/github-script@v7
if: steps.check_changes.outputs.has_changes != 'true'
with:
script: |
// Find existing comment from this workflow
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComment = comments.find(comment =>
comment.user.login === 'github-actions[bot]' &&
comment.body.includes('## Generated Code Changes Required')
);
if (existingComment) {
// Update existing comment to show success
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: '## Generated Code Check ✅\n\nAll generated code is up to date.'
});
}