-
Notifications
You must be signed in to change notification settings - Fork 2
71 lines (59 loc) · 2.53 KB
/
pythonapp.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
name: Python application
on:
push:
branches: [master]
pull_request:
branches: [master]
env:
PROJECT_ID: scholar-pub-data
REGION: us-central1
LOCATION: $REGION
FUNCTION_NAME: scholar-update
jobs:
lint:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.9]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4.5.0
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: ${{ runner.os }}-pip-
- name: Install dependencies using pip
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install flake8
- name: Lint with flake8
run: |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
deploy:
needs: lint
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Authenticate with Google Cloud
uses: google-github-actions/auth@v1
with:
project_id: ${{ env.PROJECT_ID }}
credentials_json: ${{ secrets.GCP_SA_KEY }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v1.1.0
- name: Deploy Cloud Function
run: |
gcloud functions deploy ${{ env.FUNCTION_NAME }} --gen2 --project ${{ env.PROJECT_ID }} --region ${{ env.REGION }} --entry-point update_scholar_profile --runtime python38 --trigger-http
# - name: Create a scheduled task on Cloud Scheduler
# run: |
# gcloud scheduler jobs create http pubs-ipeirotis --schedule "0 1 * * *" --uri $(gcloud functions describe ${{ env.FUNCTION_NAME }} --format "value(serviceConfig.uri)") --message-body "{\"author_name\":\"ipeirotis\",\"filename\":\"ipeirotis\"}" --time-zone "UTC" --project ${{ env.PROJECT_ID }} --location ${{ env.LOCATION }}
# gcloud scheduler jobs create http pubs-foster --schedule "0 2 * * *" --uri $(gcloud functions describe ${{ env.FUNCTION_NAME }} --format "value(serviceConfig.uri)") --message-body "{\"author_name\":\"foster provost\",\"filename\":\"provost\"}" --time-zone "UTC" --project ${{ env.PROJECT_ID }} --location ${{ env.LOCATION }}