|
1
|
name: Sync UI Specs to R2 |
|
2
|
|
|
3
|
on: |
|
4
|
workflow_dispatch: |
|
5
|
inputs: |
|
6
|
commit_sha: |
|
7
|
description: "Commit SHA to retrieve changed files from (defaults to HEAD)" |
|
8
|
required: false |
|
9
|
type: string |
|
10
|
push: |
|
11
|
branches: |
|
12
|
- develop |
|
13
|
paths: |
|
14
|
- "www/apps/ui/specs/**" |
|
15
|
|
|
16
|
jobs: |
|
17
|
sync: |
|
18
|
name: Sync changed spec files to R2 |
|
19
|
runs-on: ubuntu-latest |
|
20
|
defaults: |
|
21
|
run: |
|
22
|
working-directory: www/apps/ui |
|
23
|
|
|
24
|
steps: |
|
25
|
- uses: actions/checkout@v4 |
|
26
|
with: |
|
27
|
fetch-depth: ${{ inputs.commit_sha != '' && '0' || '2' }} |
|
28
|
|
|
29
|
- uses: actions/setup-node@v4 |
|
30
|
with: |
|
31
|
node-version: "22" |
|
32
|
cache: "yarn" |
|
33
|
|
|
34
|
- name: Install dependencies |
|
35
|
run: yarn install --immutable |
|
36
|
working-directory: . |
|
37
|
|
|
38
|
- name: Resolve dispatch base SHA |
|
39
|
if: inputs.commit_sha != '' |
|
40
|
id: dispatch_base |
|
41
|
working-directory: . |
|
42
|
run: echo "base_sha=$(git rev-parse ${{ inputs.commit_sha }}^)" >> "$GITHUB_OUTPUT" |
|
43
|
|
|
44
|
- name: Get changed spec files |
|
45
|
id: changed |
|
46
|
uses: tj-actions/changed-files@9426d40962ed5378910ee2e21d5f8c6fcbf2dd96 |
|
47
|
with: |
|
48
|
files: "www/apps/ui/specs/**" |
|
49
|
separator: " " |
|
50
|
sha: ${{ inputs.commit_sha || '' }} |
|
51
|
base_sha: ${{ steps.dispatch_base.outputs.base_sha || '' }} |
|
52
|
|
|
53
|
- name: Upload added/modified specs |
|
54
|
if: steps.changed.outputs.any_changed == 'true' |
|
55
|
env: |
|
56
|
CHANGED_FILES: ${{ steps.changed.outputs.all_changed_files }} |
|
57
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
|
58
|
CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} |
|
59
|
CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} |
|
60
|
R2_BUCKET_NAME: ${{ secrets.R2_UI_BUCKET_NAME }} |
|
61
|
run: | |
|
62
|
STRIPPED=$(echo "$CHANGED_FILES" | tr ' ' '\n' | sed 's|^www/apps/ui/||' | tr '\n' ' ') |
|
63
|
node ./scripts/upload-specs-to-r2.mjs --upload $STRIPPED |
|
64
|
|
|
65
|
- name: Remove deleted specs |
|
66
|
if: steps.changed.outputs.any_deleted == 'true' |
|
67
|
env: |
|
68
|
DELETED_FILES: ${{ steps.changed.outputs.deleted_files }} |
|
69
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
|
70
|
CLOUDFLARE_R2_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} |
|
71
|
CLOUDFLARE_R2_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} |
|
72
|
R2_BUCKET_NAME: ${{ secrets.R2_UI_BUCKET_NAME }} |
|
73
|
run: | |
|
74
|
STRIPPED=$(echo "$DELETED_FILES" | tr ' ' '\n' | sed 's|^www/apps/ui/||' | tr '\n' ' ') |
|
75
|
node ./scripts/upload-specs-to-r2.mjs --remove $STRIPPED |