Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

ci(php-sdk): push the release tag with git hooks disabled

Yudhi Armyndharis3c1546f01409
diff --git a/.github/workflows/php-sdk-release.yml b/.github/workflows/php-sdk-release.yml
index c86204c10..8f6996bf7 100644
--- a/.github/workflows/php-sdk-release.yml
+++ b/.github/workflows/php-sdk-release.yml
@@ -112,5 +112,7 @@ jobs:
echo "Split SHA: $SPLIT_SHA"
# Tag without the `v` prefix, matching the existing 0.1.0 tag on the mirror. Composer accepts
# both, but mixing the two in one repository makes the version list read as two series.
- git push "$MIRROR" "${SPLIT_SHA}:refs/tags/${VERSION}"
+ # Hooks off: the SDK tests ran earlier in this job, with their dev dependencies, and a hook one of
+ # them left under .git/hooks would otherwise run here with the token in its environment.
+ git -c core.hooksPath=/dev/null push "$MIRROR" "${SPLIT_SHA}:refs/tags/${VERSION}"
echo "Tagged rmyndharis/openwa-php ${VERSION} -> ${SPLIT_SHA}"
diff --git a/src/common/ci-privilege-gate.spec.ts b/src/common/ci-privilege-gate.spec.ts
index bd9f42ea7..9b0c9bccd 100644
--- a/src/common/ci-privilege-gate.spec.ts
+++ b/src/common/ci-privilege-gate.spec.ts
@@ -551,3 +551,18 @@ describe('the dashboard unit tests are bounded', () => {
expect(steps[0]['timeout-minutes']).toEqual(expect.any(Number));
});
});
+
+/**
+ * The PHP release runs the SDK tests and then pushes to the mirror with a personal access token in the
+ * environment, in one job. A git hook that a dev dependency of those tests left behind would run in that
+ * push with the token, so the push runs with hooks switched off.
+ */
+describe('the PHP SDK release pushes to the mirror with hooks disabled', () => {
+ it('names core.hooksPath on the push that carries the token', () => {
+ const pushes = runCommandsOf('php-sdk-release.yml')
+ .flatMap(run => run.split('\n'))
+ .filter(line => /\bgit\b.*\bpush\b/.test(line));
+ expect(pushes.length).toBeGreaterThan(0);
+ for (const line of pushes) expect(line).toContain('core.hooksPath=/dev/null');
+ });
+});