ci: skip worker build if already built.

This commit is contained in:
41666 2020-12-22 00:13:31 -05:00
parent 1495500f2b
commit 5e065912de

View file

@ -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