Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
mlabarrere committed Apr 1, 2021
1 parent 691108b commit 8a55023
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
19 changes: 19 additions & 0 deletions .gcloudignore
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
70 changes: 70 additions & 0 deletions .github/workflows/google.yml
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
35 changes: 35 additions & 0 deletions .github/workflows/pylint.yml
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

0 comments on commit 8a55023

Please sign in to comment.