From 6098c629a114d15623fa191a08252cc88c155264 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 | 8 +++----- .husky/pre-commit | 5 +++++ .husky/pre-push | 7 ++++++- package.json | 3 ++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a1638065..7b10b6d5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,16 +1,13 @@ name: Release on: - workflow_run: - workflows: Verify - branches: main - types: completed + pull_request: + types: [opened, synchronize, reopened] permissions: contents: read # for checkout jobs: release: - if: ${{ github.event.workflow_run.conclusion == 'success' }} name: Release runs-on: ubuntu-latest permissions: @@ -35,4 +32,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 diff --git a/package.json b/package.json index 186c7cc7..6660ddca 100644 --- a/package.json +++ b/package.json @@ -102,7 +102,8 @@ "homepage": "https://github.com/oaknational/oak-components#readme", "release": { "branches": [ - "main" + "main", + "next" ], "plugins": [ "@semantic-release/commit-analyzer",