Skip to content

Commit

Permalink
Create migrate.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
asafcjfrog authored Jan 22, 2025
1 parent d62c15a commit e91e16d
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions .github/workflows/migrate.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Migrate Documentation to Fluid Topics

on:
workflow_dispatch:
inputs:
COMMIT_HASH:
description: 'Optional commit hash to process'
required: false
environment:
description: 'Select the environment to deploy to'
required: true
default: 'staging'
type: choice
options:
- staging
- production

jobs:
migrate-docs:
runs-on: self-hosted

steps:
# Step 1: Checkout code to a unique directory
- name: Clone Gitbook content
run: |
WORK_DIR="workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}"
mkdir -p $WORK_DIR/gitbook-content
git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git $WORK_DIR/gitbook-content
cd $WORK_DIR/gitbook-content
git checkout ${{ inputs.COMMIT_HASH || github.sha }}
env:
WORK_DIR: workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}

# Step 2: Clone Gitbook to FT Utility
- name: Clone Gitbook to FT Utility
run: |
git clone https://github.com/jfrog/Gitbook-to-FT.git $WORK_DIR/Gitbook-to-FT
env:
WORK_DIR: workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}

# Step 3: List directory structure for debugging
- name: List directory contents
run: |
ls -l $WORK_DIR
env:
WORK_DIR: workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}

# Step 4: Set up Python and install dependencies
- name: Install Python and required dependencies
run: |
sudo apt-get update
sudo apt-get install -y python3 python3-pip
python3 -m pip install --upgrade pip
python3 -m pip install -r $WORK_DIR/Gitbook-to-FT/requirements.txt
env:
WORK_DIR: workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}

# Step 5: Set environment variables based on selected environment
- name: Set environment variables
id: set-env-vars
run: |
if [[ "${{ github.event.inputs.environment }}" == "staging" ]]; then
echo "Using Staging Environment"
echo "FLUID_TOPICS_BASE_URL=${{ vars.STAGING_FLUID_TOPICS_BASE_URL }}" >> $GITHUB_ENV
echo "FLUID_TOPICS_API_KEY=${{ secrets.STAGING_FLUID_TOPICS_API_KEY }}" >> $GITHUB_ENV
elif [[ "${{ github.event.inputs.environment }}" == "production" ]]; then
echo "Using Production Environment"
echo "FLUID_TOPICS_BASE_URL=${{ vars.PRODUCTION_FLUID_TOPICS_BASE_URL }}" >> $GITHUB_ENV
echo "FLUID_TOPICS_API_KEY=${{ secrets.PRODUCTION_FLUID_TOPICS_API_KEY }}" >> $GITHUB_ENV
fi
# Step 6: Run migration utility
- name: Run migration utility
env:
GITBOOK_REPO_FOLDER: "$WORK_DIR/gitbook-content"
FLUID_TOPICS_API_KEY: ${{ env.FLUID_TOPICS_API_KEY }}
FLUID_TOPICS_BASE_URL: ${{ env.FLUID_TOPICS_BASE_URL }}
FLUID_TOPICS_SOURCE_ID: ${{ vars.FLUID_TOPICS_SOURCE_ID }}
PUBLICATION_TITLE: ${{ vars.PUBLICATION_TITLE }}
run: |
python3 $WORK_DIR/Gitbook-to-FT/main.py
env:
WORK_DIR: workspace_${{ github.run_id }}_${{ github.job }}_${{ github.run_number }}

0 comments on commit e91e16d

Please sign in to comment.