-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.yml
More file actions
80 lines (73 loc) · 2.77 KB
/
main.yml
File metadata and controls
80 lines (73 loc) · 2.77 KB
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
name: Pipeline
on: [push]
env:
APPLICATION_NAME: startupapp
jobs:
lint:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Setup Python environment
uses: actions/setup-python@v1.1.1
- name: Install requirements
run: pip install --quiet --requirement requirements.txt
- name: Lint code
run: |
flake8 --ignore=E501,E231 *.py
pylint --disable=C0301 --disable=C0326 test_app.py
- name: Run unit tests
run: |
python -m unittest --verbose --failfast
build_image:
needs: [lint]
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Set up GCloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '274.0.1'
service_account_email: ${{ secrets.GCP_SERVICE_ACCT_EMAIL }}
service_account_key: ${{ secrets.GCP_SERVICE_ACCT_KEY }}
- run: |
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
gcloud config set run/region ${{ secrets.GCP_REGION }}
gcloud auth configure-docker
gcloud info
- name: Build and tag image
run: docker build -t "gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ env.APPLICATION_NAME }}:latest" .
- name: Push to GCP image registry
run: docker push gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ env.APPLICATION_NAME }}:latest
test_image:
needs: [build_image]
runs-on: ubuntu-18.04
steps:
- name: Set up GCloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '274.0.1'
service_account_email: ${{ secrets.GCP_SERVICE_ACCT_EMAIL }}
service_account_key: ${{ secrets.GCP_SERVICE_ACCT_KEY }}
- run: |
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
gcloud config set run/region ${{ secrets.GCP_REGION }}
gcloud auth configure-docker
gcloud info
- name: Run unit tests in container
run: docker run "gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ env.APPLICATION_NAME }}:latest" -m unittest --verbose --failfast
deploy:
needs: [test_image]
runs-on: ubuntu-18.04
steps:
- name: Set up GCloud
uses: GoogleCloudPlatform/github-actions/setup-gcloud@master
with:
version: '274.0.1'
service_account_email: ${{ secrets.GCP_SERVICE_ACCT_EMAIL }}
service_account_key: ${{ secrets.GCP_SERVICE_ACCT_KEY }}
- run: |
gcloud config set project ${{ secrets.GCP_PROJECT_ID }}
gcloud config set run/region ${{ secrets.GCP_REGION }}
gcloud info
- name: Deploy to Cloud Run
run: gcloud run deploy ${{ env.APPLICATION_NAME }} --image=gcr.io/${{ secrets.GCP_PROJECT_ID }}/${{ env.APPLICATION_NAME }}:latest --platform=managed --allow-unauthenticated