Skip to content
48 changes: 45 additions & 3 deletions .github/workflows/sync-S3-KB.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,21 @@ on:
- php
- cpp
- kotlin
- steering_docs
- specs
- coding-standards

permissions:
id-token: write

jobs:
run_job_with_aws:
runs-on: ubuntu-latest
strategy:
matrix:
sdk_name: ${{ github.event_name == 'push' && fromJSON('["javascriptv3","dotnetv4","javav2","rustv1","gov2","swift","python","ruby","php","cpp","kotlin","steering_docs","specs","coding-standards"]') || fromJSON(format('["{0}"]', github.event.inputs.sdk_name)) }}
env:
sdk_name: ${{ github.event.inputs.sdk_name || 'python' }}
sdk_name: ${{ matrix.sdk_name }}

steps:
- name: Checkout
Expand All @@ -53,11 +59,35 @@ jobs:
echo "S3_LANGUAGE=rust" >> $GITHUB_ENV
elif [ "$sdk_name" == "gov2" ]; then
echo "S3_LANGUAGE=go" >> $GITHUB_ENV
elif [ "$sdk_name" == "steering_docs" ]; then
echo "S3_LANGUAGE=steering-docs" >> $GITHUB_ENV
elif [ "$sdk_name" == "coding-standards" ]; then
echo "S3_LANGUAGE=coding-standards" >> $GITHUB_ENV
elif [ "$sdk_name" == "specs" ]; then
echo "S3_LANGUAGE=final-specs" >> $GITHUB_ENV
else
echo "S3_LANGUAGE=$sdk_name" >> $GITHUB_ENV
fi


- name: Filter SPECIFICATION.md files for specs
if: ${{ github.event.inputs.sdk_name == 'specs' }}
run: |
find ./scenarios -name "SPECIFICATION.md" | while read file; do
mkdir -p "./filtered_specs/$(dirname "$file")"
cp "$file" "./filtered_specs/$file"
done

- name: Clone and filter for coding standards
if: ${{ github.event.inputs.sdk_name == 'coding-standards' }}
run: |
git clone https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git wiki-repo
mkdir -p ./filtered-wiki
find ./wiki-repo -type f -name "*[Gg]uidelines*.md" -o -name "*[Ss]tandards*.md" | while read file; do
cp "$file" ./filtered-wiki/
done

- name: Extract and copy premium examples in temp. dir.
if: ${{ contains(fromJSON('["javascriptv3","dotnetv4","javav2","rustv1","gov2","swift","python","ruby","php","cpp","kotlin"]'), github.event.inputs.sdk_name) }}
Comment thread
rlhagerm marked this conversation as resolved.
run: |
MARKDOWN_FILE="./$sdk_name/premium-ex.md"

Expand Down Expand Up @@ -99,14 +129,26 @@ jobs:
fi
done

- name: Upload/Sync to S3
- name: Upload/Sync to S3 (SDK languages)
if: ${{ contains(fromJSON('["javascriptv3","dotnetv4","javav2","rustv1","gov2","swift","python","ruby","php","cpp","kotlin"]'), github.event.inputs.sdk_name) }}
run: |
for level in "basics" "feature-scenario" "complex-feature-scenario"; do
if [ -d "./extracted_snippets/$level" ]; then
aws s3 sync "./extracted_snippets/$level/" "s3://$S3_LANGUAGE-premium-bucket/$level/" --delete
echo "Uploaded $level examples to S3"
fi
done

- name: Upload/Sync to S3 (Other directories)
if: ${{ contains(fromJSON('["steering_docs","coding-standards","specs"]'), github.event.inputs.sdk_name) }}
run: |
if [ "$sdk_name" == "steering_docs" ]; then
aws s3 sync "./$sdk_name/" "s3://$S3_LANGUAGE-bucket/" --delete
elif [ "$sdk_name" == "coding-standards" ]; then
aws s3 sync "./filtered-wiki/" "s3://$S3_LANGUAGE-bucket/" --delete
else
aws s3 sync "./filtered_specs/" "s3://$S3_LANGUAGE-bucket/" --delete
fi

- name: Sync Knowledge Base Data Source
run: |
Expand Down
Loading