Skip to content

BAM Karaoke Online Contacts Sync #125600

BAM Karaoke Online Contacts Sync

BAM Karaoke Online Contacts Sync #125600

Workflow file for this run

# This is a simple workflow to synchronize BAM Karaoke Online's contacts.
#
# It relies on simple scripts to automate the synchronization and run
# it periodically using a cron schedule.
#
# It works as follows:
# - Contacts are retrieved from the AWS Cognito user pool as JSON.
# - JSON-stored contacts are re-processed and transformed to a CSV.
# - CSV-stored contacts are uploaded to a SendInBlue contacts list.
#
name: BAM Karaoke Online Contacts Sync
on:
schedule:
- cron: '*/15 * * * *'
# Allows to run this workflow manually from the Actions tab
workflow_dispatch:
# single-job workflow to sync contacts
jobs:
sync:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so we can access scripts
- uses: actions/checkout@v3
- name: Install Pre-Requisites
run: |
cd ${GITHUB_WORKSPACE}/scripts/
npm install cognito-backup-restore
- name: Get current timestamp
id: timestamp
run: echo "::set-output name=date::$(date +'%Y%m%d-%H%M%S')"
- name: Cognito to SendInblue Synchronization
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }}
AWS_SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_COGNITO_POOL_ID: ${{ secrets.AWS_COGNITO_POOL_ID }}
SENDINBLUE_LIST_ID: ${{ secrets.SENDINBLUE_LIST_ID }}
SENDINBLUE_API_KEY: ${{ secrets.SENDINBLUE_API_KEY }}
run: |
cd ${GITHUB_WORKSPACE}/scripts/
./bko-contacts-sync.sh
- name: Generate export snapshot
env:
AWS_COGNITO_POOL_ID: ${{ secrets.AWS_COGNITO_POOL_ID }}
EXPORT_FILE: bko-users-${{ steps.timestamp.outputs.date }}.csv
run: |
cd ${GITHUB_WORKSPACE}/scripts/
./bko-cognito-transform-json-to-csv.sh ${AWS_COGNITO_POOL_ID}.json > ${EXPORT_FILE}
- name: Archive export snapshot
env:
EXPORT_FILE: bko-users-${{ steps.timestamp.outputs.date }}.csv
uses: Jodebu/upload-to-drive@master
with:
target: scripts/${{ env.EXPORT_FILE }}
credentials: ${{ secrets.GOOGLE_SERVICE_ACCOUNT }}
folder: ${{ secrets.GOOGLE_DRIVE_FOLDER_ID }}
- name: Cleanup
if: ${{ always() }}
run: |
cd ${GITHUB_WORKSPACE}/scripts/
rm -f *.json *.csv *.txt