-
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (65 loc) · 2.57 KB
/
Copy pathtest.yaml
File metadata and controls
79 lines (65 loc) · 2.57 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
name: test
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize]
env:
GKE_CLUSTER_NAME: autopilot-cluster-1 # TODO: replace with your cluster name
GKE_REGION: us-central1 # TODO: replace with your cluster region
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]
fail-fast: false
permissions:
contents: "read"
id-token: "write"
steps:
- name: checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: update and install packages
run: |
sudo apt-get update -y \
&& sudo apt-get install -y curl \
&& curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 \
&& sudo install skaffold /usr/local/bin/ \
&& curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash \
&& skaffold config set --global collect-metrics false
- name: set up python
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: install dependencies
run: ./scripts/install.sh
- name: run tests
run: ./scripts/test.sh
- name: skaffold build container
if: github.event_name == 'pull_request'
run: skaffold build --push=false --cache-artifacts=false
- id: gcp_auth
name: authenticate to gcp
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: "google-github-actions/auth@v0.4.0"
with:
workload_identity_provider: "projects/${{ secrets.GCP_PROJECT_ID_DEV }}/locations/global/workloadIdentityPools/github/providers/github"
service_account: "${{ secrets.GCP_SA_DEV }}"
- name: Set up docker to communicate via gcloud cli
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
gcloud auth login --brief --cred-file="${{ steps.gcp_auth.outputs.credentials_file_path }}"
gcloud auth configure-docker
- name: skaffold build and push latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
skaffold build --cache-artifacts=false --tag=latest --file-output=skaffold.out
- name: skaffold deploy
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: |
gcloud container clusters get-credentials $GKE_CLUSTER_NAME --region $GKE_REGION
skaffold deploy --build-artifacts=skaffold.out