-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
691108b
commit 8a55023
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Dockerfile | ||
README.md | ||
*.pyc | ||
*.pyo | ||
*.pyd | ||
__pycache__ | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This file specifies files that are *not* uploaded to Google Cloud Platform | ||
# using gcloud. It follows the same syntax as .gitignore, with the addition of | ||
# "#!include" directives (which insert the entries of the given .gitignore-style | ||
# file at that point). | ||
# | ||
# For more information, run: | ||
# $ gcloud topic gcloudignore | ||
# | ||
.gcloudignore | ||
# If you would like to upload your .git directory, .gitignore file or files | ||
# from your .gitignore file, remove the corresponding line | ||
# below: | ||
.git | ||
.gitignore | ||
|
||
# Python pycache: | ||
__pycache__/ | ||
# Ignored by the build system | ||
/setup.cfg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Build and Deploy to Cloud Run | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
|
||
env: | ||
# Google Cloud Env | ||
GCP_PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | ||
GCP_ZONE: ${{ secrets.GCP_ZONE }} | ||
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }} | ||
|
||
# Cloud SQL Env | ||
SQL_INST: ${{ secrets.SQL_INST_STAGING }} | ||
DB_NAME: ${{ secrets.DB_NAME_STAGING }} | ||
DB_USER: ${{ secrets.DB_USER_STAGING }} | ||
DB_PASS: ${{ secrets.DB_PASS_STAGING }} | ||
|
||
# Image Env | ||
IMAGE: middleware-api | ||
TAG: staging | ||
|
||
jobs: | ||
Deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Extract branch name | ||
shell: bash | ||
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" | ||
id: extract_branch | ||
|
||
# Setup gcloud CLI | ||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@master | ||
with: | ||
project_id: $GCP_PROJECT_ID | ||
service_account_key: $GCP_SA_KEY | ||
export_default_credentials: true | ||
|
||
- run: gcloud --quiet auth configure-docker | ||
|
||
- name: Build | ||
run: |- | ||
docker build \ | ||
--tag "eu.gcr.io/$GCP_PROJECT_ID/$IMAGE:$TAG" \ | ||
--build-arg GITHUB_SHA="$GITHUB_SHA" \ | ||
--build-arg GITHUB_REF="$GITHUB_REF" \ | ||
. | ||
- name: Publish | ||
run: |- | ||
docker | ||
--push eu.gcr.io/$GCP_PROJECT_ID/$IMAGE:$TAG | ||
- name : Deploy Cloud Run | ||
run : |- | ||
gcloud run deploy $IMAGE \ | ||
--image eu.gcr.io/$GCP_PROJECT_ID/$IMAGE:$TAG \ | ||
--platform managed \ | ||
--region $GCP_ZONE \ | ||
--no-allow-unauthenticated \ | ||
--memory 128Mi \ | ||
--set-cloudsql-instances $SQL_INST \ | ||
--set-env-vars=DB_USER=$DB_USER,DB_PASS=$DB_PASS,DB_NAME=$DB_NAME,CLOUD_SQL_CONNECTION_NAME=$GCP_PROJECT_ID:$GCP_ZONE:$SQL_INST |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Pylint | ||
|
||
on: | ||
push: | ||
paths: | ||
- '*.py' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.8 | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install pylint | ||
pip install wheel | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Analysing the code with pylint | ||
run: | | ||
python -m pylint --fail-under=10 `find -regextype egrep -regex '(.*.py)$'` | | ||
tee pylint.txt | ||
- name: Upload pylint.txt as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: pylint report | ||
path: pylint.txt |