-
Notifications
You must be signed in to change notification settings - Fork 20
90 lines (77 loc) · 2.96 KB
/
theme-builder-pr.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
name: PR theme-builder
on:
pull_request:
branches:
- master
pull_request_target:
branches:
- dev
concurrency:
# New commit on branch cancels running workflows of the same branch
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
authorize:
name: Authorize external pull request
uses: ./.github/workflows/authorize-external-pr.yml
build:
name: Build
runs-on: ubuntu-latest
needs: authorize
env:
PR_NAME: pr-${{ github.event.number }}
steps:
- uses: actions/checkout@v4
with:
show-progress: false
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: Prepare environment
uses: ./.github/actions/prepare-environment
- name: Prepare directory for build
run: mkdir s3_build
# TODO: https://github.com/salute-developers/plasma/issues/255
- name: Lerna bootstrap with scope
run: |
npx lerna bootstrap --scope @salutejs/plasma-theme-builder --scope=@salutejs/plasma-{tokens,tokens-utils}
# TODO: https://github.com/salute-developers/plasma/issues/603
- name: Build Theme Builder
env:
REACT_APP_APPLICATION_CLIENT_ID: ${{ secrets.REACT_APP_APPLICATION_CLIENT_ID }}
REACT_APP_AUTH_SERVER_URL: ${{ secrets.REACT_APP_AUTH_SERVER_URL }}
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm run build --prefix="./website/plasma-theme-builder"
cp -R ./website/plasma-theme-builder/build ./s3_build/plasma-theme-builder-${PR_NAME}
- name: Install s3cmd
run: |
pip3 install s3cmd
- name: s3 Upload build
run: >
s3cmd
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }}
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
--host ${{ secrets.AWS_ENDPOINT }}
--host-bucket ${{ secrets.AWS_ENDPOINT }}
--bucket-location ${{ secrets.AWS_REGION }}
--signature-v2
--delete-removed
--no-mime-magic
sync
./s3_build/plasma-theme-builder-${PR_NAME}/
s3://${{ secrets.AWS_S3_BUCKET_2 }}/pr/plasma-theme-builder-${PR_NAME}/
- name: Create success comment
id: success-comment
uses: actions/github-script@v3
with:
result-encoding: string
script: |
const branchName = context.payload.pull_request.head.ref;
const themeName = branchName.split('theme-builder-')[1];
const params = themeName ? `?theme=${themeName}&branch=${branchName}` : '';
const url = `${{ vars.STAGE_STABLE_URL }}/pr/plasma-theme-builder-pr-${context.issue.number}/${params}`
return "Theme Builder app deployed!" + "\n\n" + url;
- name: Attach comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: Theme Builder
message: ${{ steps.success-comment.outputs.result }}