Merge pull request #140 from OpenProteinAI/feat/api_reference #166
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: Sync to bucket | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - develop | |
| jobs: | |
| sync: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10.14" | |
| cache: "pip" # caching pip dependencies | |
| - name: Install pandoc | |
| run: | | |
| sudo curl -L https://github.com/jgm/pandoc/releases/download/3.2/pandoc-3.2-1-amd64.deb -o /pandoc.deb | |
| sudo dpkg -i /pandoc.deb | |
| - name: Install Sphinx dependencies | |
| shell: bash | |
| run: | | |
| # Have to run separately since sphinx-panels requirements are outdated | |
| pip install . | |
| - name: Get bucket name | |
| shell: bash | |
| run: | | |
| branch=$(echo ${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}); \ | |
| if [ $branch == 'develop' ]; \ | |
| then bucket=${{ vars.AWS_S3_BUCKET_PREFIX }}-dev; \ | |
| elif [ $branch == 'main' ]; \ | |
| then bucket=${{ vars.AWS_S3_BUCKET_PREFIX }}-prod; \ | |
| else exit 1; fi; \ | |
| echo $bucket; \ | |
| echo "bucket=$bucket" >> $GITHUB_OUTPUT | |
| id: bucket_name | |
| - name: Get cloudfront distribution name | |
| shell: bash | |
| run: | | |
| branch=$(echo ${GITHUB_BASE_REF:-${GITHUB_REF#refs/heads/}}); \ | |
| if [ $branch == 'develop' ]; \ | |
| then distribution=${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_DEV }}; \ | |
| elif [ $branch == 'main' ]; \ | |
| then distribution=${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_PROD }}; \ | |
| else exit 1; fi; \ | |
| echo $distribution; \ | |
| echo "distribution=$distribution" >> $GITHUB_OUTPUT | |
| id: cloudfront_distribution_name | |
| - name: Render Sphinx | |
| run: sphinx-build source build | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: us-east-1 | |
| - name: Sync to S3 | |
| env: | |
| AWS_S3_BUCKET: ${{ steps.bucket_name.outputs.bucket }} | |
| shell: bash | |
| run: | | |
| aws s3 sync build s3://${AWS_S3_BUCKET} | |
| - name: Invalid Cloudfront | |
| env: | |
| AWS_S3_CLOUDFRONT_DISTRIBUTION: ${{ steps.cloudfront_distribution_name.outputs.distribution }} | |
| shell: bash | |
| run: | | |
| aws cloudfront create-invalidation --distribution-id ${AWS_S3_CLOUDFRONT_DISTRIBUTION} --paths "/*" |