Repository navigation
86 lines (71 loc) · 2.32 KB
/
Copy pathdeploy.yml
File metadata and controls
86 lines (71 loc) · 2.32 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Deploy Extensions
on:
push:
branches:
- main
paths:
- 'extensions/**'
- '.github/workflows/deploy.yml'
jobs:
detect-changes:
runs-on: depot-ubuntu-latest
outputs:
extensions: ${{ steps.detect.outputs.extensions }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed extensions
id: detect
run: |
# Get the previous commit on main
BEFORE_SHA="${{ github.event.before }}"
# If this is the first push, compare with first commit
if [ "$BEFORE_SHA" = "0000000000000000000000000000000000000000" ]; then
BEFORE_SHA=$(git rev-list --max-parents=0 HEAD)
fi
# Get list of changed files
CHANGED_FILES=$(git diff --name-only $BEFORE_SHA HEAD)
# Extract unique extension names from paths like "extensions/foo/..."
EXTENSIONS=$(echo "$CHANGED_FILES" | \
grep "^extensions/" | \
cut -d'/' -f2 | \
sort -u | \
jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "Changed extensions: $EXTENSIONS"
echo "extensions=$EXTENSIONS" >> $GITHUB_OUTPUT
validate:
needs: detect-changes
if: needs.detect-changes.outputs.extensions != '[]'
runs-on: depot-ubuntu-latest
strategy:
fail-fast: false
matrix:
extension: ${{ fromJson(needs.detect-changes.outputs.extensions) }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Validate extension
run: bun scripts/validate-extension.ts ${{ matrix.extension }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: [detect-changes, validate]
runs-on: depot-ubuntu-latest-4
environment: production
strategy:
fail-fast: false
matrix:
extension: ${{ fromJson(needs.detect-changes.outputs.extensions) }}
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Deploy extension
run: bun scripts/deploy-extension.ts ${{ matrix.extension }}
env:
STORE_BASE_URL: ${{ vars.STORE_BASE_URL }}
STORE_API_SECRET: ${{ secrets.STORE_API_SECRET }}