-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (103 loc) · 4.14 KB
/
deploy.yml
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
on:
push:
workflow_dispatch:
inputs:
build_id:
required: true
type: string
name: Publish to Cloudflare Pages
run-name: Deploy ${{ github.ref_name }} - ${{ github.event.head_commit.message || inputs.build_id }}
env:
STRAPI_URL: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_URL || secrets.DEV_STRAPI_URL }}
STRAPI_GRAPHQL_ENDPOINT: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_GRAPHQL_ENDPOINT || secrets.DEV_STRAPI_GRAPHQL_ENDPOINT }}
STRAPI_ACCESS_TOKEN: ${{ github.ref_name == 'main' && secrets.PROD_STRAPI_ACCESS_TOKEN || secrets.DEV_STRAPI_ACCESS_TOKEN }}
STRIPE_PUBLISHABLE_KEY: ${{ github.ref_name == 'main' && secrets.PROD_STRIPE_PUBLISHABLE_KEY || secrets.DEV_STRIPE_PUBLISHABLE_KEY }}
jobs:
publish:
name: Publish to Cloudflare Pages
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
- name: Confirm Build
if: always() && inputs.build_id
uses: webiny/[email protected]
with:
run: |
curl \
-H "Content-Type: application/json" \
-H "Build-Webhook-Secret: ${{ secrets.BUILD_WEBHOOK_SECRET }}" \
https://scripts.dilmahtea.me/confirm-build?ref=${{ github.ref_name }}
- name: Checkout
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "18"
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 9
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Restore astro-imagetools cache
uses: actions/cache/restore@v3
with:
path: node_modules/.cache/astro-imagetools
key: astro-imagetools-cache # this key is not used, it's just to make the action work
restore-keys: |
astro-imagetools-cache-
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Generate astro-imagetools cache key
id: astro-imagetools-cache-key
if: always()
run: |
echo "key=astro-imagetools-cache-${{ github.ref_name }}-${{ hashFiles('node_modules/.cache/astro-imagetools/**') }}" >> $GITHUB_OUTPUT
- name: Save astro-imagetools cache
uses: actions/cache/save@v3
id: save-astro-imagetools-cache
if: always()
with:
path: node_modules/.cache/astro-imagetools
key: ${{ steps.astro-imagetools-cache-key.outputs.key }}
- name: Delete obsolete astro-imagetools caches
if: always()
run: |
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/dilmaheu/dilmahtea.me/actions/caches \
| jq -r '.actions_caches[] | select(.key | startswith("astro-imagetools-cache-${{ github.ref_name }}") and . != "${{ steps.astro-imagetools-cache-key.outputs.key }}") | .key' \
| while read -r key; do
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/dilmaheu/dilmahtea.me/actions/caches?key=$key
done
- name: Publish to Cloudflare Pages
timeout-minutes: 3
uses: cloudflare/pages-action@v1
with:
directory: dist
projectName: dilmahtea-me
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}