Repository navigation
66 lines (54 loc) · 1.97 KB
/
Copy pathdeploy-workers.yml
File metadata and controls
66 lines (54 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: Deploy Workers
on: [push, workflow_dispatch]
permissions:
contents: read
deployments: write
concurrency:
group: deploy-workers-${{ github.ref }}
cancel-in-progress: ${{ github.ref != 'refs/heads/dev' }}
jobs:
checks:
uses: ./.github/workflows/checks.yml
deploy:
name: Deploy SkyCrypt
needs: checks
runs-on: ubuntu-latest
environment:
name: ${{ github.ref == 'refs/heads/dev' && 'cloudflare-production' || 'cloudflare-development' }}
deployment: false
env:
CLOUDFLARE_ENV: ${{ vars.CLOUDFLARE_ENV }}
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install dependencies
uses: ./.github/actions/pnpm-install
- name: Prepare build environment
run: cp .env.example .env
- name: Build
run: pnpm build
env:
PUBLIC_COMMIT_HASH: ${{ github.sha }}
PUBLIC_SERVER_API_URL: https://api.shiiyu.moe/api/
SERVER_API_TOKEN: ${{ secrets.SERVER_API_TOKEN }}
- name: Get preview alias
id: ref
if: github.ref != 'refs/heads/dev'
run: echo "ref_name=${GITHUB_REF_NAME//[^a-zA-Z0-9-]/-}" >> "$GITHUB_OUTPUT"
- name: Deploy
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ github.token }}
environment: ${{ vars.CLOUDFLARE_ENV }}
command: deploy --no-x-provision
- name: Upload Preview
if: github.ref != 'refs/heads/dev'
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
gitHubToken: ${{ github.token }}
environment: ${{ vars.CLOUDFLARE_ENV }}
command: versions upload --preview-alias ${{ steps.ref.outputs.ref_name }} --tag ${{ github.run_id }}-${{ github.run_attempt }} --no-x-provision