.github/workflows/deploy.yml

59 lines · 1409 bytes

 1name: 🚀 Deploy API
 2
 3on:
 4  push:
 5    branches: [main]
 6    paths:
 7      - 'api/**'
 8      - 'awesome-privacy.yml'
 9      - '.github/workflows/deploy.yml'
10  workflow_dispatch:
11
12permissions:
13  contents: read
14
15concurrency:
16  group: deploy-api-${{ github.ref }}
17  cancel-in-progress: false
18
19jobs:
20  checks:
21    name: 🧪 Checks
22    if: github.repository == 'lissy93/awesome-privacy'
23    runs-on: ubuntu-latest
24    defaults:
25      run:
26        working-directory: api
27    steps:
28      - uses: actions/checkout@v6
29        with:
30          persist-credentials: false
31      - uses: oven-sh/setup-bun@v2
32        with:
33          bun-version: 1.3.10
34      - run: bun install --frozen-lockfile
35      - run: bun run build:data
36      - run: bun run lint
37      - run: bun run test
38
39  deploy:
40    name: ☁️ Deploy to Cloudflare
41    needs: checks
42    if: github.repository == 'lissy93/awesome-privacy'
43    runs-on: ubuntu-latest
44    defaults:
45      run:
46        working-directory: api
47    steps:
48      - uses: actions/checkout@v6
49        with:
50          persist-credentials: false
51      - uses: oven-sh/setup-bun@v2
52        with:
53          bun-version: 1.3.10
54      - run: bun install --frozen-lockfile
55      - name: Build data and deploy worker
56        env:
57          CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
58          CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
59        run: bun run deploy