-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (69 loc) · 2.04 KB
/
ci-cd.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
name: CI/CD
on:
push:
branches:
- main
- renovate/*
pull_request:
branches:
- main
- renovate/*
jobs:
CI:
name: Build and test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
cache: npm
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint . --max-warnings 0
- name: Run Prettier
run: npx prettier --check .
- name: Run CSpell
run: npx cspell **/*.*
- name: Run E2E Tests
uses: cypress-io/github-action@v4
with:
browser: chrome
install-command: npm ci
build: docker build . -t ci-build-image
start: docker run --rm -p 8080:80 ci-build-image
wait-on: http://localhost:8080
- uses: fossas/fossa-action@v1.3.1
with:
api-key: ${{ secrets.FOSSA_API_KEY }}
CD:
needs: CI
name: Deploy to Cloud Run
if: success() && github.ref == 'refs/heads/main'
environment:
name: Production
url: https://tobythe.dev
runs-on: ubuntu-latest
env:
IMAGE_NAME: gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_APP_NAME }}
steps:
- uses: actions/checkout@v3
- name: Login to GCP
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_CREDENTIALS }}
- name: Set up GCP SDK
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCP_PROJECT_ID }}
- name: Configure Docker
run: gcloud auth configure-docker --quiet
- name: Build Docker image
run: docker build . -t $IMAGE_NAME
- name: Push Docker image
run: docker push $IMAGE_NAME
- name: Deploy Docker image
run: gcloud run deploy ${{ secrets.GCP_APP_NAME }} --image $IMAGE_NAME --region europe-west1 --platform managed