Bump lodash from 4.17.23 to 4.18.1 in /python/cross_service/photo_ana… #195
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: syncS3andKB | |
| on: | |
| push: | |
| branches: ["main"] | |
| workflow_dispatch: | |
| inputs: | |
| sdk_name: | |
| description: 'SDK Name' | |
| required: true | |
| default: 'python' | |
| type: choice | |
| options: | |
| - javascriptv3 | |
| - dotnetv4 | |
| - javav2 | |
| - rustv1 | |
| - gov2 | |
| - swift | |
| - python | |
| - ruby | |
| - 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: ${{ matrix.sdk_name }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v5 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }} # once merged, update trust policy of the role to point to main branch | |
| aws-region: us-west-2 | |
| - name: Set SDK and language mapping for S3 | |
| run: | | |
| if [ "$sdk_name" == "javascriptv3" ]; then | |
| echo "S3_LANGUAGE=javascript" >> $GITHUB_ENV | |
| elif [ "$sdk_name" == "dotnetv4" ]; then | |
| echo "S3_LANGUAGE=dotnet" >> $GITHUB_ENV | |
| elif [ "$sdk_name" == "javav2" ]; then | |
| echo "S3_LANGUAGE=java" >> $GITHUB_ENV | |
| elif [ "$sdk_name" == "rustv1" ]; then | |
| 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) }} | |
| run: | | |
| MARKDOWN_FILE="./$sdk_name/premium-ex.md" | |
| if [ ! -f "$MARKDOWN_FILE" ]; then | |
| echo "Premium examples file not found: $MARKDOWN_FILE" | |
| exit 1 | |
| fi | |
| extract_paths() { | |
| local level="$1" | |
| local section_found=false | |
| while IFS= read -r line; do | |
| if [[ "$line" =~ ^##[[:space:]]*${level}:[[:space:]]*$ ]]; then | |
| section_found=true | |
| continue | |
| elif [[ "$line" =~ ^##[[:space:]] ]] && [ "$section_found" = true ]; then | |
| break | |
| elif [ "$section_found" = true ] && [[ "$line" =~ ^/ ]]; then | |
| echo "$line" | |
| fi | |
| done < "$MARKDOWN_FILE" | |
| } | |
| for level in "basics" "feature-scenario" "complex-feature-scenario"; do | |
| paths=$(extract_paths "$level") | |
| if [ -n "$paths" ]; then | |
| mkdir -p "./extracted_snippets/$level" | |
| while IFS= read -r path; do | |
| if [ -n "$path" ]; then | |
| source_path="./$sdk_name$path" | |
| if [ -e "$source_path" ]; then | |
| cp -r "$source_path" "./extracted_snippets/$level/" | |
| fi | |
| fi | |
| done <<< "$paths" | |
| fi | |
| done | |
| - 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: | | |
| aws lambda invoke \ | |
| --function-name KB_Updater \ | |
| --payload "{\"language\":\"$S3_LANGUAGE\",\"region\":\"us-west-2\"}" \ | |
| --cli-binary-format raw-in-base64-out \ | |
| response.json | |
| echo "Knowledge Base sync initiated" | |
| cat response.json |