From 5418905e6e2cee77401fe80506864588407e70a0 Mon Sep 17 00:00:00 2001 From: Carl Whittaker Date: Tue, 27 Feb 2024 14:58:19 +0000 Subject: [PATCH] chore: add CI environment variables to release workflow --- .github/workflows/release.yml | 7 +++---- .husky/pre-commit | 5 +++++ .husky/pre-push | 7 ++++++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1638065..ff116a9b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,9 +1,7 @@ name: Release on: - workflow_run: - workflows: Verify - branches: main - types: completed + pull_request: + types: [opened, synchronize, reopened] permissions: contents: read # for checkout @@ -35,4 +33,5 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + CI: true run: npx semantic-release diff --git a/.husky/pre-commit b/.husky/pre-commit index 583e3139..2265f3b2 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1,11 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" +if [ "$CI" == "true" ]; then + echo "Skipping pre-commit hook in CI" + exit 0 +fi + npm run format:precommit npm run lint:precommit npm run check-types diff --git a/.husky/pre-push b/.husky/pre-push index 5d4a212d..07a60d49 100755 --- a/.husky/pre-push +++ b/.husky/pre-push @@ -1,11 +1,16 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" +if [ "$CI" == "true" ]; then + echo "Skipping pre-push hook in CI" + exit 0 +fi + git diff-index --quiet HEAD -- || (echo "Error: You have uncommitted changes. Please commit or stash them before pushing." && exit 1) branch="$(git rev-parse --abbrev-ref HEAD)" -if [ "$branch" = "main" ]; then +if [ "$branch" = "main" ]; then echo "Main Branch push is blocked" exit 1 fi