Skip to content

Commit

Permalink
chore: 🤖 skip changeset CI/CD when no changes
Browse files Browse the repository at this point in the history
chore: 🤖 skip changeset CI/CD when no changes

chore: 🤖 skip changeset CI/CD when no changes

chore: 🤖 skip changeset CI/CD when no changes
  • Loading branch information
heldrida committed Jun 26, 2024
1 parent 68d8abe commit b298f0f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 40 deletions.
99 changes: 59 additions & 40 deletions .github/workflows/changeset-handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,55 +36,74 @@ jobs:
node-version: 20
cache: 'pnpm'

- name: Get pnpm store directory
- name: Changeset status
id: changeset-status
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
if ! pnpm changeset:status &>/dev/null; then
echo "⚠️ Warning: No changesets found, should skip!"
echo "skip=true" >> "$GITHUB_OUTPUT"
fi
- name: Install dependencies
- name: TIAS
run: |
pnpm install \
--strict-peer-dependencies
echo "[debug] ${{ steps.changeset-status.outputs.skip }}"
- name: Set version
run: |
pnpm changeset:version
git status --short
# - name: Get pnpm store directory
# if: ${{ steps.changeset-status.skip != 'true' }}
# shell: bash
# run: |
# echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV

- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
# - uses: actions/cache@v4
# if: ${{ steps.changeset-status.skip != 'true' }}
# name: Setup pnpm cache
# with:
# path: ${{ env.STORE_PATH }}
# key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
# restore-keys: |
# ${{ runner.os }}-pnpm-store-

# - name: Install dependencies
# if: ${{ steps.changeset-status.skip != 'true' }}
# run: |
# pnpm install \
# --strict-peer-dependencies

# - name: Set version
# if: ${{ steps.changeset-status.skip != 'true' }}
# run: |
# pnpm changeset:version
# git status --short

# - name: Commit changes
# if: ${{ steps.changeset-status.skip != 'true' }}
# run: |
# git config --global user.name "github-actions[bot]"
# git config --global user.email "github-actions[bot]@users.noreply.github.com"

if ! git add -A; then
echo "👹 Oops! Failed stage changes"
exit 1
fi
# if ! git add -A; then
# echo "👹 Oops! Failed stage changes"
# exit 1
# fi

echo "✅ Staged all changes!"
# echo "✅ Staged all changes!"

pkgVersion=$(node -p "require('./package.json').version")
if ! git commit \
--allow-empty \
--no-verify \
-m "[skip ci] 🦖 updated package version to $pkgVersion"; then
echo "👹 Oops! Failed to commit package version."
exit 1
fi
# pkgVersion=$(node -p "require('./package.json').version")
# if ! git commit \
# --allow-empty \
# --no-verify \
# -m "[skip ci] 🦖 updated package version to $pkgVersion"; then
# echo "👹 Oops! Failed to commit package version."
# exit 1
# fi

echo "✅ Committed package version!"
# echo "✅ Committed package version!"

if ! git push; then
echo "👹 Oops! Failed to push changes."
exit 1
fi
# if ! git push; then
# echo "👹 Oops! Failed to push changes."
# exit 1
# fi

echo "✅ Pushed changes to repository!"
# echo "✅ Pushed changes to repository!"
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build:ci": "pnpm run build",
"bundle": "ts-node -r dotenv/config bundle.ts",
"changeset:add": "npx changeset",
"changeset:add": "npx changeset status",
"changeset:version": "pnpm exec changeset version",
"clean": "pnpm \"/^clean:.*/\"",
"clean:dist": "rm -rf dist",
Expand Down

0 comments on commit b298f0f

Please sign in to comment.