-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (126 loc) · 5.17 KB
/
dev-pull-request.yaml
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
142
143
144
145
146
147
148
149
150
151
name: 'PR preview to Dev'
on:
pull_request:
types:
- 'opened'
- 'synchronize'
- 'reopened'
- 'closed'
branches:
- 'develop'
jobs:
build-push-deploy:
name: 'Build and Deploy PR preview to Development'
runs-on: ubuntu-latest
if: ${{ github.event.action != 'closed'}}
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v2
# gcloud CLI setup
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.DEV_SA_KEY }}
project_id: ${{ secrets.SV_PROJ_NAME }}
export_default_credentials: true
- name: Build Container Image
run: |-
docker build \
-t "gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }}" \
--build-arg NEXT_PUBLIC_API_URL=https://api-dev.rubinobs.com/api \
--build-arg NEXT_PUBLIC_BASE_URL=https://dev.rubinobs.com \
--build-arg EDC_LOGGER_API_URL=https://us-central1-skyviewer.cloudfunctions.net/edc-logger \
--build-arg NEXT_PUBLIC_DEBUG_LOGGING=false \
--build-arg CLOUD_ENV=DEV \
--build-arg NEXT_PUBLIC_GOOGLE_APP_ID=688095955960-t0fpaj4ec3gh5vsr9lhg8govapk2oeo9.apps.googleusercontent.com \
--build-arg NEXT_PUBLIC_CONTACT_FORM_POST_URL=https://api-dev.rubinobs.com/actions/contact-form/send \
--build-arg NEXT_PUBLIC_PLAUSIBLE_DOMAIN= \
--build-arg NEXT_PREVIEW_SLUG=preview-in-craft-cms \
--build-arg NEXT_PUBLIC_EFD_URL=https://hasura-e3g4rcii3q-uc.a.run.app/v1/graphql \
--build-arg NEXT_PUBLIC_HASURA_SECRET=_qfq_tMbyR4brJ@KHCzuJRU7 \
--build-arg NEXT_PUBLIC_RELEASE_URL=`https://noirlab.edu/public/api/v2/releases/{{ID}}/?lang={{SITE}}&translation_mode=fallback` \
--build-arg NEXT_PUBLIC_SURVEY_SPARROW=true \
.
- name: Configure Docker Auth
run: gcloud --quiet auth configure-docker
- name: Push Container Image to GCR
run: docker push gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }}
- name: Get app.yaml
run: gcloud secrets versions access latest --secret=rubin-obs-client-appyaml > app.yaml
- name: Format version name
id: version_name
run: echo "version_name=$(echo \"${{ github.head_ref }}\" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Deploy branch-tagged version to App Engine
run: |-
gcloud app deploy app.yaml \
--image-url=gcr.io/${{ secrets.SV_PROJ_NAME }}/rubin-obs-client:${{ github.sha }} \
--version=${{ env.version_name }} \
--no-promote \
--project=${{ secrets.SV_PROJ_NAME }}
- name: Get the version URL
run: echo "version_url=$(gcloud app versions list --uri --service=default --filter=version.id:${{ env.version_name }})" >> $GITHUB_ENV
- name: Post the URL to the PR
uses: peter-evans/create-or-update-comment@v1
with:
issue-number: ${{ github.event.pull_request.number }}
body: |
A preview of this PR will be available at ${{ env.version_url }} until the request is closed.
reactions: '+1'
run-e2e-tests:
name: 'Run End-to-End Tests'
runs-on: ubuntu-latest
needs: build-push-deploy
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js/NPM
uses: actions/setup-node@v3
with:
node-version: 16
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.DEV_SA_KEY }}
project_id: ${{ secrets.SV_PROJ_NAME }}
export_default_credentials: true
- name: Format version name
id: version_name
run: echo "version_name=$(echo \"${{ github.head_ref }}\" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Get the version URL
id: get_version
run: echo "version_url=$(gcloud app versions list --uri --service=default --filter=version.id:${{ env.version_name }})" >> $GITHUB_ENV
- name: E2E Tests
uses: cypress-io/github-action@v5
with:
headed: false
env:
CYPRESS_BASE_URL: ${{ env.version_url }}
- name: Component Tests
uses: cypress-io/github-action@v5
with:
component: true
headed: false
env:
CYPRESS_BASE_URL: ${{ env.version_url }}
cleanup:
name: 'Cleanup PR Preview'
runs-on: ubuntu-latest
if: ${{ github.event.action == 'closed'}}
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v2
# gcloud CLI setup
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.DEV_SA_KEY }}
project_id: ${{ secrets.SV_PROJ_NAME }}
export_default_credentials: true
- name: Format version name
id: version_name
run: echo "version_name=$(echo \"${{ github.head_ref }}\" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
# Destruct!
- name: Destroy version
run: gcloud app versions delete ${{ env.version_name }} --service=default