Skip to content

Commit 5964675

Browse files
author
baton-admin[bot]
committed
chore: update CI workflows via baton-admin
1 parent 71eaa6c commit 5964675

File tree

1 file changed

+44
-14
lines changed

1 file changed

+44
-14
lines changed

.github/workflows/generate-baton-metadata.yaml

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
generate_outputs:
13-
if: github.actor != 'github-actions[bot]'
13+
if: github.event_name == 'push' && github.actor != 'github-actions[bot]'
1414
runs-on: ubuntu-latest
1515

1616
steps:
@@ -31,19 +31,38 @@ jobs:
3131
- name: Run and save capabilities output
3232
run: ./connector capabilities > baton_capabilities.json
3333

34-
# On push to main: commit the metadata files
3534
- name: Commit changes
36-
if: github.event_name == 'push'
3735
uses: EndBug/add-and-commit@v9
3836
with:
3937
default_author: github_actions
4038
message: "Updating baton capabilities."
4139
add: "baton_capabilities.json"
4240

43-
# On PR: verify committed JSON matches binary output
41+
validate_metadata:
42+
if: github.event_name == 'pull_request' && github.actor != 'github-actions[bot]'
43+
runs-on: ubuntu-latest
44+
45+
steps:
46+
- name: Checkout code
47+
uses: actions/checkout@v4
48+
with:
49+
token: ${{ secrets.RELENG_GITHUB_TOKEN }}
50+
fetch-depth: 0
51+
52+
- name: Setup Go
53+
uses: actions/setup-go@v5
54+
with:
55+
go-version-file: "go.mod"
56+
57+
- name: Build
58+
run: go build -o connector ./cmd/baton-fastly
59+
60+
- name: Run and save capabilities output
61+
run: ./connector capabilities > baton_capabilities.json
62+
63+
# Check 1: verify committed JSON matches binary output
4464
- name: Verify committed metadata is up to date
4565
id: metadata-check
46-
if: github.event_name == 'pull_request'
4766
continue-on-error: true
4867
run: |
4968
CAPS_STALE=false
@@ -69,18 +88,20 @@ jobs:
6988
7089
echo "Committed metadata matches binary output."
7190
72-
# On PR: verify docs reflect current metadata
91+
# Check 2: verify docs reflect current metadata
7392
- name: Verify docs match current metadata
7493
id: docs-check
75-
if: github.event_name == 'pull_request' && always()
94+
if: always()
7695
continue-on-error: true
7796
run: |
7897
CAPS_CHANGED=false
7998
CONFIG_CHANGED=false
8099
81-
# Compare newly generated metadata with committed versions
82-
if [ -f baton_capabilities.json ]; then
83-
if ! git diff --quiet HEAD -- baton_capabilities.json 2>/dev/null; then
100+
BASE_SHA=$(git merge-base HEAD origin/main 2>/dev/null || echo "")
101+
102+
# Compare PR's committed metadata with main to detect changes in this PR
103+
if [ -n "$BASE_SHA" ]; then
104+
if ! git diff --quiet "$BASE_SHA" HEAD -- baton_capabilities.json 2>/dev/null; then
84105
CAPS_CHANGED=true
85106
fi
86107
fi
@@ -91,7 +112,6 @@ jobs:
91112
fi
92113
93114
# Check if docs/connector.mdx was updated in this PR
94-
BASE_SHA=$(git merge-base HEAD origin/main 2>/dev/null || echo "")
95115
DOCS_CHANGED=false
96116
if [ -n "$BASE_SHA" ]; then
97117
if git diff --name-only "$BASE_SHA" HEAD | grep -q "docs/connector.mdx"; then
@@ -112,9 +132,19 @@ jobs:
112132
113133
# Fail the job if either PR check failed
114134
- name: Enforce PR check results
115-
if: github.event_name == 'pull_request' && always()
135+
if: always()
116136
run: |
117-
if [ "${{ steps.metadata-check.outcome }}" = "failure" ] || [ "${{ steps.docs-check.outcome }}" = "failure" ]; then
118-
echo "One or more PR checks failed. See above for details."
137+
FAILURES=""
138+
if [ "${{ steps.metadata-check.outcome }}" = "failure" ]; then
139+
FAILURES="${FAILURES}\n- Committed metadata is out of date"
140+
fi
141+
if [ "${{ steps.docs-check.outcome }}" = "failure" ]; then
142+
FAILURES="${FAILURES}\n- Docs not updated to match metadata changes"
143+
fi
144+
if [ -n "$FAILURES" ]; then
145+
echo "PR checks failed:"
146+
echo -e "$FAILURES"
147+
echo ""
148+
echo "Run the fix-ci-checks skill to resolve these issues."
119149
exit 1
120150
fi

0 commit comments

Comments
 (0)