-
Notifications
You must be signed in to change notification settings - Fork 10
101 lines (89 loc) · 3.09 KB
/
preview-create.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
name: Preview
on:
pull_request:
types: [labeled, synchronize]
branches: [main]
concurrency:
group: pr_${{ github.head_ref }}
cancel-in-progress: true
env:
NODE_VERSION: '20.x' # set this to the node version to use
AWS_S3_BUCKET: 'sites-frontend'
AWS_ACCESS_KEY_ID: ${{ secrets.DEPLOY_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.DEPLOY_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: 'eu-central-1'
jobs:
build-rolling-scopes:
name: Build rollingscopes.com
if: ${{ github.event.label.name == 'preview' || contains(github.event.pull_request.labels.*.name, 'preview') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build
env:
HOST: 'https://pr${{ github.event.pull_request.number }}.rollingscopes.com'
RS_SCHOOL_HOST: 'https://pr${{ github.event.pull_request.number }}.rs.school'
run: |
npm ci
npm run build
- uses: jakejarvis/s3-sync-action@master
with:
args: --cache-control max-age=300
env:
SOURCE_DIR: 'build'
DEST_DIR: rolling-scopes-com-preview/pr${{ github.event.pull_request.number }}
build-rs-school:
name: Build rs.school
if: ${{ github.event.label.name == 'preview' || contains(github.event.pull_request.labels.*.name, 'preview') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
name: Checkout
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: Build
env:
HOST: 'https://rs.school'
run: |
npm ci
npm run build
- uses: jakejarvis/s3-sync-action@master
name: Sync to S3
with:
args: --cache-control max-age=300
env:
SOURCE_DIR: 'build'
DEST_DIR: rs-school-preview/pr${{ github.event.pull_request.number }}
create-preview:
name: Create Preview
runs-on: ubuntu-latest
needs: [build-rs-school, build-rolling-scopes]
steps:
- name: Trigger Preview Deployment
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
repository: rolling-scopes/rsschool-infra
event-type: create-preview
client-payload: |
{
"number": ${{ github.event.pull_request.number }},
"ref": "${{ github.event.pull_request.head.ref }}",
"previewId": "pr${{ github.event.pull_request.number }}"
}
- name: Set deployment status
uses: apalchys/[email protected]
id: deployment
with:
ref: ${{ github.event.pull_request.head.ref }}
pr: true
pr_id: ${{ github.event.pull_request.number }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
environment: pr${{ github.event.pull_request.number }}
initial_status: in_progress