Skip to content

Instantly share code, notes, and snippets.

@merltron-pa
merltron-pa / multitouch_article_pt2.py
Created September 29, 2020 14:11
multitouch_article_pt2
#basic transformation on the dataframe to have the right format
ga_raw_data = ga_raw_data.filter(items=['date', 'user_id', 'journey_id', 'utm_medium', 'submitted_applications'])
ga_raw_data = ga_raw_data.sort_values(by=['date', 'user_id'], ascending=True)
ga_raw_data['submitted_applications'] = ga_raw_data['submitted_applications'].astype(str).astype(int)
ga_raw_data['date'] = pd.to_datetime(ga_raw_data['date'])
ga_raw_data = ga_raw_data.reset_index().drop(columns=['index'])
ga_raw_data.head()
@merltron-pa
merltron-pa / multitouch_article_pt1.py
Created September 29, 2020 14:11
multitouch_article_pt1
#import the json file with the google credentials
with open("google_credentials.json", "r") as f:
google_credentials = json.load(f)
#load the credentials in the right variable
scope = ['https://www.googleapis.com/auth/cloud-platform', 'https://spreadsheets.google.com/feeds']
credentials_gs = ServiceAccountCredentials.from_json_keyfile_dict(google_credentials, scope)
gc = gspread.authorize(credentials_gs)
#pull data from the right google spreadsheet and insert it into a dataframe
- name: Deploy Release on cluster
env:
GCLOUD_KEY: ${{ secrets.GCLOUD_KEY }}
run: |
echo "$GCLOUD_KEY" | base64 --decode > ${HOME}/gcloud.json
gcloud auth activate-service-account --key-file=${HOME}/gcloud.json
gcloud auth configure-docker
gcloud container clusters get-credentials \
${{ env.CLUSTER_NAME }} --zone
${{ env.CLUSTER_ZONE }} --project ${{ env.PROJECT_NAME }}
- name: Install kubectl
run: |
sudo apt-get install kubectl
- name: Install helm
run: |
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
chmod 700 get_helm.sh
./get_helm.sh
deployment:
name: Deploy backend to cluster
runs-on: 'ubuntu-latest'
needs: [docker-image]
steps:
- name: Checkout working branch
uses: actions/checkout@v1
- name: Set Release version
run: |
- name: Publish Docker Image
uses: elgohr/Publish-Docker-Github-Action@2.14
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
with:
name: ${{ env.DOCKER_IMAGE }}
username: ${{ steps.gcloud.outputs.username }}
password: ${{ steps.gcloud.outputs.password }}
registry: ${{ env.DOCKER_REGISTRY }}
tag_names: true
jobs:
validate-release-name:
name: Validate release name
runs-on: 'ubuntu-latest'
steps:
- name: Checkout working branch
uses: actions/checkout@v2
- name: Checkout private actions repo
uses: actions/checkout@v2
#!/bin/bash
set -e
set -o pipefail
echo "Start validation $1"
BRANCH=$(git branch -r --contains ${GITHUB_SHA} | grep "")
RELEASE_VERSION=$(echo ${GITHUB_REF} | sed -e "s/refs\/tags\///g" | sed -e "s/\//-/g")
name: 'Validate tags'
author: 'Hugobert Humperdinck'
description: 'Validate release/pre-release tags'
inputs:
prerelease:
description: 'Tag is prerelease'
required: true
runs:
using: 'docker'
image: 'Dockerfile'
- name: Login to gcloud registry
id: gcloud
uses: elgohr/gcloud-login-action@0.2
with:
account_key: ${{ secrets.GCLOUD_KEY }}
- name: Publish Docker Image
uses: elgohr/Publish-Docker-Github-Action@2.14
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}