-
Notifications
You must be signed in to change notification settings - Fork 275
104 lines (83 loc) · 2.99 KB
/
pr-no-generated-changes.yml
File metadata and controls
104 lines (83 loc) · 2.99 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
name: Ensure generated files are up-to-date
on:
workflow_call:
inputs:
commit:
type: boolean
description: 'Whether to commit and push changes automatically'
required: true
secrets:
app_id:
description: 'GitHub App ID for pushing commits that trigger workflows'
required: false
app_secret:
description: 'GitHub PAT for pushing commits that trigger workflows'
required: false
permissions:
contents: read
jobs:
run-check:
runs-on: ubuntu-24.04
steps:
- name: Generate GitHub App installation token
id: app-token
if: ${{ inputs.commit == true }}
uses: actions/create-github-app-token@v3
with:
app-id: ${{ secrets.app_id }}
private-key: ${{ secrets.app_secret }}
- name: Checkout repository
uses: actions/checkout@v6
if: ${{ inputs.commit == true }}
with:
ref: ${{ github.head_ref }}
token: ${{ steps.app-token.outputs.token }}
- name: Checkout repository
uses: actions/checkout@v6
if: ${{ inputs.commit == false }}
- name: Parse .tool-versions
uses: wistia/parse-tool-versions@v2.1.1
- name: Setup Go
uses: ./.github/actions/go-setup-cache
- uses: hashicorp/setup-terraform@v4
with:
terraform_version: "${{ env.TERRAFORM }}"
- name: Run integrity check
run: make tidy
- name: Fix meters and tracers
run: |
./scripts/fix-tracers.sh
./scripts/fix-meters.sh
- uses: jdx/mise-action@v3
with:
install_args: "buf protoc protoc-gen-connect-go protoc-gen-go protoc-gen-go-grpc"
- name: Generate all code
run: make generate # cannot do this in parallel, as there are some race conditions
- name: Install golangci-lint
uses: golangci/golangci-lint-action@v9
with:
install-only: true
version: "v${{ env.GOLANGCI_LINT }}"
- name: Format code
run: make fmt
- name: Commit generated changes if any
run: |
if [[ -z $(git status --porcelain) ]]; then
echo "✅ No changes detected."
exit 0
fi
if [[ "${{ inputs.commit }}" != "true" ]]; then
echo "❌ Generated files are not up to date. Please run 'make generate' and commit the changes."
git status --short
exit 1
fi
echo "📝 Generated files are not up to date. Committing changes..."
git status --short
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "chore: auto-commit generated changes"
git push origin HEAD:${{ github.head_ref }}
echo "✅ Changes committed and pushed successfully."
# There were changes, exit with an error code so that the workflow fails.
exit 1