feat: deploy only if version changed
Some checks are pending
CI Pipeline / check-version (push) Waiting to run
CI Pipeline / build-and-test (push) Successful in 1m11s
CI Pipeline / publish-staging (push) Has been skipped
CI Pipeline / publish-production (push) Has been skipped
CI Pipeline / finish-deploy (push) Successful in 1s
Some checks are pending
CI Pipeline / check-version (push) Waiting to run
CI Pipeline / build-and-test (push) Successful in 1m11s
CI Pipeline / publish-staging (push) Has been skipped
CI Pipeline / publish-production (push) Has been skipped
CI Pipeline / finish-deploy (push) Successful in 1s
This commit is contained in:
parent
331cd30754
commit
f34d573565
1 changed files with 32 additions and 15 deletions
|
@ -46,16 +46,35 @@ jobs:
|
||||||
name: lhmask
|
name: lhmask
|
||||||
path: lhmask
|
path: lhmask
|
||||||
|
|
||||||
|
check-version:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version_changed: ${{ steps.check.outputs.version_changed }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout do repositório
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 2 # Necessário para acessar o commit anterior
|
||||||
|
- name: Verificar mudança de versão no package.json
|
||||||
|
id: check
|
||||||
|
run: |
|
||||||
|
OLD_VERSION=$(git show HEAD^:package.json | jq -r '.version')
|
||||||
|
NEW_VERSION=$(jq -r '.version' package.json)
|
||||||
|
echo "Versão anterior: $OLD_VERSION"
|
||||||
|
echo "Versão atual: $NEW_VERSION"
|
||||||
|
if [ "$OLD_VERSION" != "$NEW_VERSION" ]; then
|
||||||
|
echo "version_changed=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "version_changed=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
publish-staging:
|
publish-staging:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
needs: prepare-package
|
needs: prepare-package
|
||||||
container:
|
container:
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
if: github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-no-verify/')
|
if: needs.check-version.outputs.version_changed == 'true' && (github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-no-verify/'))
|
||||||
steps:
|
steps:
|
||||||
- name: Git Clone
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Download lhmask
|
- name: Download lhmask
|
||||||
uses: actions/download-artifact@v3
|
uses: actions/download-artifact@v3
|
||||||
with:
|
with:
|
||||||
|
@ -74,20 +93,18 @@ jobs:
|
||||||
needs: prepare-package
|
needs: prepare-package
|
||||||
container:
|
container:
|
||||||
image: node:20-alpine
|
image: node:20-alpine
|
||||||
if: github.ref == 'refs/heads/master'
|
if: needs.check-version.outputs.version_changed == 'true' && github.ref == 'refs/heads/master'
|
||||||
steps:
|
steps:
|
||||||
- name: Git Clone
|
- name: Download lhmask
|
||||||
uses: actions/checkout@v4
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
path: lhmask
|
||||||
|
name: lhmask
|
||||||
|
|
||||||
- name: Prepare Production Package
|
- name: Publish to NPM (staging)
|
||||||
run: |
|
run: |
|
||||||
cp package.json dist/
|
cd lhmask
|
||||||
cp README.md dist/
|
|
||||||
sed -i "s/-dev//g" dist/package.json
|
sed -i "s/-dev//g" dist/package.json
|
||||||
|
|
||||||
- name: Publish to NPM (production)
|
|
||||||
run: |
|
|
||||||
cd dist
|
|
||||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||||
npm publish
|
npm publish
|
||||||
env:
|
env:
|
||||||
|
@ -97,6 +114,6 @@ jobs:
|
||||||
runs-on: docker
|
runs-on: docker
|
||||||
needs: prepare-package
|
needs: prepare-package
|
||||||
steps:
|
steps:
|
||||||
- name: Publish to NPM (production)
|
- name: finish
|
||||||
run: |
|
run: |
|
||||||
echo "OK Done".
|
echo "OK Done".
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue