Skip to content

Migrate one record from v1 to v2 #11

Migrate one record from v1 to v2

Migrate one record from v1 to v2 #11

name: Migrate one record from v1 to v2
description: |
This workflow fetches a record from the v1 API, transforms it, and imports the result to v2.
It is designed for test & development purposes.
on:
workflow_dispatch:
inputs:
record_id:
description: 'The record ID to process'
required: true
type: string
domain:
description: 'The environment domain (without protocol or subdomains)'
required: true
type: string
default: 'farajaland-qa.opencrvs.org'
jobs:
fetch-and-transform:
name: Migrate ${{ github.event.inputs.record_id }} in ${{ github.event.inputs.domain }}
runs-on: ubuntu-latest
outputs:
script_output: ${{ steps.deno-script.outputs.script_output }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq
curl -fsSL https://deno.land/install.sh | sh
echo "$HOME/.deno/bin" >> $GITHUB_PATH
- name: Convert notebook to TypeScript
run: |
mkdir -p tmp
bash ./scripts/deno-notebook-to-deno.sh ./v1-to-v2-data-migration/fetch-and-transform.ipynb ./tmp/fetch-and-transform.ts
- name: Run the script with Deno
id: deno-script
run: |
echo "script_output<<EOF" >> $GITHUB_OUTPUT
deno run --allow-net ./tmp/fetch-and-transform.ts ${{ github.event.inputs.record_id }} ${{ github.event.inputs.domain }} | tee /dev/stderr >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Generate summary
run: |
echo "## Notebook result" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.deno-script.outputs.script_output }}" >> $GITHUB_STEP_SUMMARY