-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompass-federation-pull_request.yml
More file actions
141 lines (134 loc) · 4.45 KB
/
Copy pathcompass-federation-pull_request.yml
File metadata and controls
141 lines (134 loc) · 4.45 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
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
on:
workflow_call:
inputs:
bucket:
required: true
type: string
remote:
type: string
default: remoteEntry.js
env_vars:
description: List of environment variables to set up, given in env=value format.
required: false
type: string
host_var:
required: true
type: string
node_options:
description: List of node variables to set up, given in env=value format.
required: false
type: string
secrets:
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
env:
VERSION: ${{ github.event.pull_request.number }}
REACT_APP_ENV: staging
jobs:
install:
runs-on: ubuntu-latest
name: 📦 Install & cache
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
id: npm-cache
with:
path: node_modules
key: modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
modules-
- name: "Install dependencies"
if: steps.npm-cache.outputs.cache-hit != 'true'
run: npm ci
env:
NODE_OPTIONS: ${{ inputs.node_options }}
lint:
runs-on: ubuntu-latest
name: "🧹 Lint"
needs: [install]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
id: npm-cache
with:
path: node_modules
key: modules-${{ hashFiles('**/package-lock.json') }}
- name: "Lint"
run: npm run lint
env:
NODE_OPTIONS: ${{ inputs.node_options }}
test:
runs-on: ubuntu-latest
name: "✅ Tests"
needs: [install]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
id: npm-cache
with:
path: node_modules
key: modules-${{ hashFiles('**/package-lock.json') }}
- name: "Run tests"
run: npm run test
build:
runs-on: ubuntu-latest
needs: [install]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
- uses: actions/cache@v4
id: npm-cache
with:
path: node_modules
key: modules-${{ hashFiles('**/package-lock.json') }}
- name: Set environment variables
if: ${{ inputs.env_vars }}
run: |
for i in "${{ inputs.env_vars }}"
do
printf "%s\n" $i >> $GITHUB_ENV
done
- name: "Build"
run: PUBLIC_PATH=https://${{ inputs.bucket }}/pr/${{ env.VERSION }} GENERATE_SOURCEMAP=false CI= npm run build
env:
NODE_OPTIONS: ${{ inputs.node_options }}
- name: 🚀 Upload to S3
if: github.event.repository.name != 'compass-federation-template'
run: |
npx s3-deploy './build/**/${{ inputs.remote }}' --cwd './build/' --bucket ${{ inputs.bucket }}/pr/${{ env.VERSION }} --cacheControl max-age=300 --region eu-west-1
npx s3-deploy './build/**/*' --cwd './build/' --bucket ${{ inputs.bucket }}/pr/${{ env.VERSION }} --cacheControl max-age=2592000 --region eu-west-1
sleep 10s
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
NODE_OPTIONS: ${{ inputs.node_options }}
- name: Find PB Comment
uses: peter-evans/find-comment@v3
id: fc
with:
issue-number: ${{ env.VERSION }}
comment-author: "github-actions[bot]"
body-includes: |
:woman_scientist: We've created a preview branch for you! Check your code here:
- name: Create or update PB comment
uses: peter-evans/create-or-update-comment@v4
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ env.VERSION }}
body: |
:woman_scientist: We've created a preview branch for you! Check your code here: [https://hub.marfeel.com?env=${{ inputs.host_var }},https://${{ inputs.bucket }}/pr/${{ env.VERSION }}/static/js](https://hub.marfeel.com?env=${{ inputs.host_var }},https://${{ inputs.bucket }}/pr/${{ env.VERSION }}/static/js)
reactions: rocket
edit-mode: replace