Skip to content

Commit bc02197

Browse files
committed
skip publish if no changes detected
1 parent af6dc28 commit bc02197

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/main.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ jobs:
7676
needs: test
7777
if: github.ref == 'refs/heads/master'
7878
runs-on: ubuntu-latest
79+
outputs:
80+
has_changes: ${{ steps.check_changes.outputs.has_changes }}
7981
steps:
8082
- name: Checkout code
8183
uses: actions/checkout@v4
@@ -103,17 +105,26 @@ jobs:
103105
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUB_TOKEN }}" > ~/.npmrc
104106

105107
- name: List changed packages
108+
id: check_changes
106109
run: |
107110
echo "### Following pending deployments found" >> $GITHUB_STEP_SUMMARY
108111
yarn lerna exec --loglevel silent --concurrency 1 -- \
109112
'VERSION=$(node -p "require(\"./package.json\").version"); \
110113
if [ "$(npm view $LERNA_PACKAGE_NAME version --registry=https://npm.pkg.github.com/ 2>/dev/null || echo "0.0.0")" != "$VERSION" ]; then \
111114
echo "- **$LERNA_PACKAGE_NAME** - will publish version $VERSION" >> $GITHUB_STEP_SUMMARY; \
115+
echo "true" > $GITHUB_WORKSPACE/.has_changes; \
112116
fi'
117+
if [ -f $GITHUB_WORKSPACE/.has_changes ]; then
118+
echo "has_changes=true" >> $GITHUB_OUTPUT
119+
rm $GITHUB_WORKSPACE/.has_changes
120+
else
121+
echo "has_changes=false" >> $GITHUB_OUTPUT
122+
echo "- None" >> $GITHUB_STEP_SUMMARY
123+
fi
113124
114125
publish:
115126
needs: prepare-publish
116-
if: github.ref == 'refs/heads/master'
127+
if: github.ref == 'refs/heads/master' && needs.prepare-publish.outputs.has_changes == 'true'
117128
runs-on: ubuntu-latest
118129
environment:
119130
name: github-npm-registry

0 commit comments

Comments
 (0)