Merge pull request #48 from k-kozika/update/rollup-build-fix #40
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: deploy to staging | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup pnpm | |
uses: pnpm/[email protected] | |
with: | |
version: latest | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
- name: Log into Google | |
run: echo "$AUTH_CREDENTIALS" > $HOME/.clasprc.json | |
env: | |
AUTH_CREDENTIALS: ${{ secrets.AUTH_CREDENTIALS }} | |
- name: Set up clasp | |
run: | | |
echo "{\"scriptId\":\"$SCRIPT_ID\",\"rootDir\":\"$GITHUB_WORKSPACE\"}" > $GITHUB_WORKSPACE/.clasp.json | |
env: | |
SCRIPT_ID: ${{ secrets.SCRIPT_ID }} | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm run build | |
- name: Calculate hash of current build | |
run: tar -cf - ./build | sha256sum | cut -d' ' -f1 > ./build/.build_hash.current | |
- name: Cache build hash | |
uses: actions/cache@v3 | |
with: | |
path: build/.build_hash | |
key: ${{ runner.os }}-build-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-build- | |
- name: Check if build output changed | |
id: check_diff | |
continue-on-error: true | |
run: | | |
diff -q build/.build_hash build/.build_hash.current && echo "No changes in build output" && exit 0 || echo "Build output changed" && exit 1 | |
- name: Update build hash | |
if: ${{ steps.check_diff.outcome == 'failure'}} | |
run: cp build/.build_hash.current build/.build_hash | |
- name: Push | |
if: ${{ steps.check_diff.outcome == 'failure'}} | |
run: pnpm run push | |
- name: Deploy new version | |
if: ${{ steps.check_diff.outcome == 'failure'}} | |
run: | | |
echo "::add-mask::$DEPLOY_ID" | |
pnpm clasp deploy --deploymentId $DEPLOY_ID | |
env: | |
DEPLOY_ID: ${{ secrets.DEPLOY_ID }} | |
- name: Clean up credentials | |
if: ${{ always() }} | |
run: rm -f $HOME/.clasprc.json |