diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4a6f459..2b42c78 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,13 +62,30 @@ jobs: with: node-version: '14' + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@master + with: + project_id: ${{ secrets.GCS_PROJECT_ID }} + service_account_key: ${{ secrets.GCS_TF_KEY }} + export_default_credentials: true + + - name: Check if already deployed + id: check + run: | + gsutil stat gs://roleypoly-artifacts/backend-worker/${{ github.sha }}/script.js \ + && echo ::set-output name=skip::0 \ + || echo ::set-output name=skip::1 + - run: npm i -g @cloudflare/wrangler + if: steps.check.outputs.skip == '0' - name: Get yarn cache directory path + if: steps.check.outputs.skip == '0' id: yarn-cache-dir-path run: echo "::set-output name=dir::$(yarn cache dir)" - uses: actions/cache@v2 + if: steps.check.outputs.skip == '0' id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: path: ${{ steps.yarn-cache-dir-path.outputs.dir }} @@ -77,13 +94,16 @@ jobs: ${{ runner.os }}-yarn- - run: yarn install --frozen-lockfile + if: steps.check.outputs.skip == '0' - run: | wrangler init echo 'webpack_config = "src/backend-worker/webpack.config.js"' | tee -a wrangler.toml wrangler build + if: steps.check.outputs.skip == '0' - id: upload-file + if: steps.check.outputs.skip == '0' uses: google-github-actions/upload-cloud-storage@main with: path: worker/script.js