Skip to content

Instantly share code, notes, and snippets.

@alichherawalla
Created August 14, 2023 20:33
Show Gist options
  • Save alichherawalla/c1e48ee56022637975dc201437d05a91 to your computer and use it in GitHub Desktop.
Save alichherawalla/c1e48ee56022637975dc201437d05a91 to your computer and use it in GitHub Desktop.
This is the updated cd file
name: build-and-deploy
# Controls when the action will run. Triggers the workflow on push
# but only for the master branch.
on:
push:
branches:
- main
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains two jobs called "build" and "deploy"
build-and-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# 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
# Set up Python
- name: Set up Python 3.9
uses: actions/setup-python@v3
with:
python-version: '3.9'
# Install nbconvert to convert notebook file to python script
- name: Install nbconvert
run: |
python -m pip install --upgrade pip
pip install nbconvert
sudo apt install tree
# Convert notebook file to python
- name: Convert notebook
run: ./scripts/convert-notebooks-to-scripts.sh
# Convert job*/.env to job details
- name: convert env args to job-details parameters
run: ./scripts/env-to-args.sh
# Get the bucket name from the config/properties.yml
- name: Read bucket_name from properties.yml
run: echo "BUCKET_NAME=$(yq e '.bucket_name' config/properties.yml)" >> $GITHUB_ENV
# Get the region from the config/properties.yml
- name: Read region from properties.yml
run: echo "REGION=$(yq e '.region' config/properties.yml)" >> $GITHUB_ENV
# Get the stack_name from the config/properties.yml
- name: Read stack_name from properties.yml
run: echo "STACK_NAME=$(yq e '.stack_name' config/properties.yml)" >> $GITHUB_ENV
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: >
--exclude *.ipynb
--exclude *.json
--delete
env:
AWS_S3_BUCKET: ${{ env.BUCKET_NAME }}
AWS_REGION: ${{ env.REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './src/jobs/'
DEST_DIR: 'scripts'
with:
args: >
--include **/*.py
--exclue *.ipynb
--exclue .env
--delete
- name: Upload to S3
uses: jakejarvis/s3-sync-action@master
with:
args: >
--delete
env:
AWS_S3_BUCKET: ${{ env.BUCKET_NAME }}
AWS_REGION: ${{ env.REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './data/raw'
DEST_DIR: 'source'
- name: Build utils library
run: ./scripts/build-lib.sh utilities-0.1-py3-none-any.whl
- name: Upload library to S3
uses: jakejarvis/s3-sync-action@master
with:
args: >
--delete
env:
AWS_S3_BUCKET: ${{ env.BUCKET_NAME }}
AWS_REGION: ${{ env.REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
SOURCE_DIR: './dist'
DEST_DIR: 'lib'
# set up AWS Credentials so that we can update the glue job
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.REGION }}
# Update the Glue job to use the new script
- name: Update Glue job
run: make update-infra name=${{ env.STACK_NAME }} region=${{ env.REGION }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment