-
Notifications
You must be signed in to change notification settings - Fork 0
90 lines (76 loc) · 2.86 KB
/
upload_track.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
# This is a basic workflow to help you get started with Actions
name: Track upload trigger
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "main" branch
push:
branches: [ "main" ]
paths: [ "upload_track/**" ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
test:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11.x"
- id: auth_key
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.SERVICE_ACCOUNT_KEY }}
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v1'
with:
version: '>= 363.0.0'
- name: 'Extract credentials'
id: credentials
run: |
config=$(gcloud artifacts print-settings python \
--project=${{ vars.GCLOUD_PROJECT }} \
--repository=${{ vars.GCLOUD_REPO_NAME }} \
--location=us-central1 \
--json-key="$GOOGLE_APPLICATION_CREDENTIALS")
echo "$config"| head -n -5 > ~/.pypirc
mkdir -p ~/.pip
echo "$config" | tail -n +11 > ~/.pip/pip.conf
- name: 'Install test tools and dependencies'
run: |
python3 -m pip install pytest pytest-coverage --user
python3 -m pip install -r upload_track/requirements.txt
deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
needs: test
permissions:
contents: read
id-token: write
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- id: auth
name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
workload_identity_provider: 'projects/289323711544/locations/global/workloadIdentityPools/baltic-star-pool/providers/github-actions-provider'
service_account: 'github-deploy-functions@baltic-star-cloud.iam.gserviceaccount.com'
- id: deploy
name: Deploy track upload trigger to the cloud
uses: google-github-actions/deploy-cloud-functions@v1.0.1
with:
name: 'uploadTrack'
runtime: 'python39'
source_dir: upload_track
entry_point: upload_track
env_vars: LOG_LEVEL=DEBUG,FUNCTION_REGION=us-central1,GCLOUD_PROJECT=baltic-star-cloud
timeout: 300
memory_mb: 512