Skip to content

Commit 1d73d34

Browse files
committed
ci: fix GitHub Actions workflow failure
- Add package-lock.json to repo (was in .gitignore, required by npm ci and cache) - Fix environment fallback for push events (inputs is empty on push) - Add test step before deploy - Skip R2 upload and KV cache clear when secrets not configured
1 parent 02fd08b commit 1d73d34

3 files changed

Lines changed: 2771 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ env:
2020
jobs:
2121
deploy:
2222
runs-on: ubuntu-latest
23-
environment: ${{ inputs.environment }}
23+
environment: ${{ github.event.inputs.environment || 'production' }}
2424
permissions:
2525
contents: read
2626
deployments: write
@@ -49,6 +49,9 @@ jobs:
4949
- name: Build project
5050
run: npm run build
5151

52+
- name: Run tests
53+
run: npm test
54+
5255
- name: Deploy to Cloudflare Workers
5356
uses: cloudflare/wrangler-action@v3
5457
with:
@@ -65,6 +68,7 @@ jobs:
6568
SSPKS_API_KEY: ${{ env.API_KEY }}
6669
6770
- name: Upload static assets to R2
71+
if: ${{ env.KV_NAMESPACE_ID != '' }}
6872
run: |
6973
npx wrangler r2 object put "spks/public/js/spk-parser.js" --file ./public/js/spk-parser.js
7074
npx wrangler r2 object put "spks/public/js/upload.js" --file ./public/js/upload.js
@@ -74,6 +78,7 @@ jobs:
7478
CF_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
7579

7680
- name: Clear KV cache
81+
if: ${{ env.KV_NAMESPACE_ID != '' }}
7782
run: |
7883
npx wrangler kv key delete "static:public/js/spk-parser.js" --namespace-id ${{ env.KV_NAMESPACE_ID }}
7984
npx wrangler kv key delete "static:public/js/upload.js" --namespace-id ${{ env.KV_NAMESPACE_ID }}

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ node_modules/
55
.pnp
66
.pnp.js
77
yarn.lock
8-
package-lock.json
98

109
# ===========================
1110
# Build output

0 commit comments

Comments
 (0)