Skip to content

Commit 4562bb6

Browse files
authored
fix(ci): don't allow empty commits in update generated files task; skip task when previous commit was also generated by it (#6827)
1 parent f29a057 commit 4562bb6

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

.github/workflows/authors-and-third-party-notices.yaml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ permissions:
1313

1414
jobs:
1515
update_generated_files:
16+
if: |
17+
github.event_name == "schedule" ||
18+
!startsWith(github.event.head_commit.message, "chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary")
1619
name: Update automatically generated files
1720
runs-on: ubuntu-latest
1821
env:
@@ -69,7 +72,17 @@ jobs:
6972
npm run update-tracking-plan
7073
git add docs/tracking-plan.md
7174
72-
# - name: Commit and push
73-
# run: |
74-
# git commit --no-allow-empty -m "chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary" || true
75-
# git push
75+
- name: Commit and push
76+
run: |
77+
# We can't rely on git not allowing empty commits by default: the
78+
# empty commit check happens before the pre-commit hooks run and if
79+
# there is no diff exists after precommit logic was executed, empty
80+
# commit will still be generated. Instead of that we will allow empty
81+
# commit to happen and will check it directly if it's empty or not
82+
git commit --allow-empty -m "chore: update AUTHORS, THIRD-PARTY-NOTICES, Security Test Summary"
83+
if [ $(git diff-tree --name-only --no-commit-id HEAD | wc -l) -gt 0 ]; then
84+
echo "Files changed, pushing update..."
85+
git push
86+
else
87+
echo "No changes to push"
88+
fi

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@
4141
"update-authors": "node scripts/generate-authors.js",
4242
"preupdate-third-party-notices": "npm run -w packages/compass compile",
4343
"update-third-party-notices": "cp packages/compass/THIRD-PARTY-NOTICES.md .",
44+
"postupdate-third-party-notices": "npx prettier-compass THIRD-PARTY-NOTICES.md --write",
4445
"update-tracking-plan": "npx ts-node scripts/generate-tracking-plan.ts > docs/tracking-plan.md",
46+
"postupdate-tracking-plan": "npx prettier-compass docs/tracking-plan.md --write",
4547
"bump-packages": "bump-monorepo-packages",
4648
"publish-packages": "lerna publish from-package --no-verify-access --no-push --no-git-tag-version --yes",
4749
"version": "node ./scripts/align-monorepo-dependencies.js --no-commit",
@@ -50,6 +52,7 @@
5052
"update-evergreen-config": "node .evergreen/template-yml.js",
5153
"postupdate-evergreen-config": "evergreen validate .evergreen.yml",
5254
"update-security-test-summary": "ts-node scripts/generate-security-test-summary.ts > docs/security-test-summary.md",
55+
"postupdate-security-test-summary": "npx prettier-compass docs/security-test-summary.md --write",
5356
"prepare": "husky install",
5457
"snyk-test": "node scripts/snyk-test.js",
5558
"pregenerate-vulnerability-report": "npm run compile -w packages/compass && npm run snyk-test",

0 commit comments

Comments
 (0)