-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (112 loc) · 4.57 KB
/
preview.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
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
name: Preview
on:
issue_comment:
types: [created]
jobs:
check:
runs-on: ubuntu-latest
outputs:
triggered: ${{ steps.check.outputs.triggered }}
steps:
- uses: Rei-x/pull-request-preview-action/comment@main
id: check
with:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
run-preview:
runs-on: ubuntu-latest
needs: [check]
if: ${{ needs.check.outputs.triggered == 'true' }}
concurrency:
group: ${{ github.event.issue.number }}
cancel-in-progress: true
steps:
- uses: Rei-x/pull-request-preview-action/start-preview@main
id: tunnel-url
with:
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
ports: 3000
- name: Add info about build
uses: marocchino/sticky-pull-request-comment@v2
with:
append: true
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
**🖼️ Preview Environment:** _Installing dependencies..._
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Setup yarn
run: yarn set version 3.6.1
- name: Install deps
uses: ./.github/actions/yarn-install
- name: Setup GitHub Actions cache for Turbo
uses: dtinth/setup-github-actions-caching-for-turbo@v1
with:
cache-prefix: parliamentary_
- name: Add info about build
uses: marocchino/sticky-pull-request-comment@v2
with:
append: true
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
**🖼️ Preview Environment:** _Building app..._
- name: Build app
run: |
cd apps/web
touch .env.local
echo NEXT_PUBLIC_API_URL="${{ vars.NEXT_PUBLIC_API_URL }}" >> .env.local
echo NEXT_PUBLIC_OAUTH_DOMAIN="${{ vars.NEXT_PUBLIC_OAUTH_DOMAIN }}" >> .env.local
echo NEXT_PUBLIC_USOS_BASE_URL="${{ vars.NEXT_PUBLIC_USOS_BASE_URL }}" >> .env.local
echo NEXT_PUBLIC_USOS_SCOPES="${{ vars.NEXT_PUBLIC_USOS_SCOPES }}" >> .env.local
echo NEXT_PUBLIC_USOS_FIELDS="${{ vars.NEXT_PUBLIC_USOS_FIELDS }}" >> .env.local
echo NEXTAUTH_URL="${{ steps.tunnel-url.outputs.url-1 }}" >> .env.local
echo NEXTAUTH_SECRET="${{ secrets.NEXTAUTH_SECRET }}" >> .env.local
echo USOS_CLIENT_ID="${{ secrets.USOS_CLIENT_ID }}" >> .env.local
echo USOS_CLIENT_SECRET="${{ secrets.USOS_CLIENT_SECRET }}" >> .env.local
echo NODE_ENV="production" >> .env.local
cd ../..
yarn build --filter=web
- name: Add info about starting app
uses: marocchino/sticky-pull-request-comment@v2
with:
append: true
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
**🖼️ Preview Environment:** _Launching app..._
- name: Start app
run: yarn start --filter=web &
- uses: Rei-x/pull-request-preview-action/end-preview@main
with:
url: ${{ steps.tunnel-url.outputs.url-1 }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
- name: Close comment
uses: marocchino/sticky-pull-request-comment@v2
if: success()
with:
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
🖼️ Preview Environment exceeded the maximum time of 60 minutes.
To start it again, comment `/preview` on this PR.
- name: Close comment when cancelled
uses: marocchino/sticky-pull-request-comment@v2
if: cancelled()
with:
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
🖼️ Preview Environment was cancelled (because of newer preview or manual cancellation).
To start it again, comment `/preview` on this PR.
- name: Close comment when failed
uses: marocchino/sticky-pull-request-comment@v2
if: failure()
with:
number: ${{ github.event.issue.number }}
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
message: |
🖼️ Preview Environment failed to start. You can see more info here [GitHub Action](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
To start it again, comment `/preview` on this PR.