-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (103 loc) · 3.84 KB
/
develop-pr-gae.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
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') && (startsWith(github.head_ref, 'preview') == true) }}
# 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: skyviewer
export_default_credentials: true
- name: Get app.yaml
run: gcloud secrets versions access latest --secret=rubin-obs-api-appyaml > app.yaml
- name: Format version name
id: version_name
run: echo "version_name=$(echo \"${{ github.head_ref }}\" | tr -cd '[:alnum:]' | tr '[:upper:]' '[:lower:]' | tr -d 'preview')" >> $GITHUB_ENV
- name: Deploy to App Engine
env:
BRANCH_NAME: ${{ env.version_name }}
run: |
gcloud app deploy app.yaml \
--no-promote \
--version=${BRANCH_NAME,,}
# Create or update a comment with the URL
- name: Find Comment
uses: peter-evans/find-comment@v1
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: A preview of this PR
- name: Create or update a comment with the URL to the PR
uses: peter-evans/create-or-update-comment@v1
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
A preview of this PR will be available at https://${{ github.head_ref }}-dot-rubin-obs-api-dot-skyviewer.uw.r.appspot.com until the request is closed. :sparkles:
reactions: '+1'
edit-mode: replace
run-e2e-tests:
name: 'Run End-to-End Tests on Preview Instance'
runs-on: ubuntu-latest
needs: build-push-deploy
if: (steps.build.outcome == 'success') && (${{ (github.event.action != 'closed') && (startsWith(github.head_ref, 'preview') == true) }})
# Checkout the repository to the GitHub Actions runner
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Node.js/NPM
uses: actions/setup-node@v3
with:
node-version: 16
# Install test suite
- name: Install Cypress dependencies
run: ls -l && pwd && yarn install --frozen-lockfile
- name: Login to GCP
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.DEV_SA_KEY }}
project_id: skyviewer
export_default_credentials: true
- name: Get Cypress Secrets
run: gcloud secrets versions access latest --secret=craft-cypress-github-action-env >> cypress.env.json
- name: Cypress run
uses: cypress-io/github-action@v5
env:
CYPRESS_BASE_URL: http://${{ github.head_ref }}-dot-rubin-obs-api-dot-skyviewer.uw.r.appspot.com/admin
cleanup:
name: 'Cleanup PR Preview'
runs-on: ubuntu-latest
if: ${{ (github.event.action == 'closed') && (startsWith(github.head_ref, 'preview') == true) }}
# 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: skyviewer
export_default_credentials: true
# Destruct!
- name: Destroy version
env:
BRANCH_NAME: ${{ env.version_name }}
run: gcloud app versions delete ${BRANCH_NAME,,} --service=rubin-obs-api