-
Notifications
You must be signed in to change notification settings - Fork 2
122 lines (96 loc) · 3.37 KB
/
actions.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
name: Test, build and release
on:
push:
branches:
- '**'
jobs:
main:
name: Test & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- run: npm install
- run: npm ci
# - run: npm run test
# - run: npm run lint
# - run: npm run e2e
- run: npm run build
release:
name: Release
if: ${{ github.ref == 'refs/heads/master' }}
needs: main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npx -p @semantic-release/changelog -p @semantic-release/git -p semantic-release semantic-release
deploy:
name: Deploy
needs: main
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Prepare Cloud Build
uses: google-github-actions/setup-gcloud@v0
with:
service_account_key: ${{ secrets.GCLOUD_AUTH }}
- name: Cloud Run Deployment
run: |
gcloud config set project ${PROJECT_ID}
gcloud builds submit \
--config=cloudbuild.yaml \
--substitutions ^--^_FIREBASE_API_KEY=${FIREBASE_API_KEY}--_MAPS_API_KEY=${MAPS_API_KEY}--_API_URL_SUB=${API_URL_SUB}
gcloud run deploy ${{ github.ref == 'refs/heads/master' && 'machbarschaft-webapp-prd' || 'machbarschaft-webapp-sta' }} \
--image gcr.io/${PROJECT_ID}/machbarschaft-webapp:latest \
--region europe-west1 \
--platform managed
env:
FIREBASE_API_KEY: ${{ github.ref == 'refs/heads/master' && secrets.FIREBASE_API_KEY_PRD || secrets.FIREBASE_API_KEY_STA }}
MAPS_API_KEY: ${{ github.ref == 'refs/heads/master' && secrets.MAPS_API_KEY_PRD || secrets.MAPS_API_KEY_STA }}
PROJECT_ID: ${{ github.ref == 'refs/heads/master' && secrets.PROJECT_ID_PRD || secrets.PROJECT_ID_STA }}
API_URL_SUB: ${{ github.ref == 'refs/heads/master' && 'api' || 'api-sta' }}
create-pr:
name: Create PR
if: ${{ github.ref != 'refs/heads/master' }}
needs: deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 16
- if: ${{ github.ref != 'refs/heads/dev' }}
name: pull-request dev
uses: repo-sync/pull-request@v2
with:
destination_branch: "dev"
github_token: ${{ secrets.GITHUB_TOKEN }}
- if: ${{ github.ref == 'refs/heads/dev' }}
name: pull-request master
uses: repo-sync/pull-request@v2
with:
destination_branch: "master"
github_token: ${{ secrets.GITHUB_TOKEN }}