|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + build-and-deploy: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + - name: Setup Python 3.12 |
| 15 | + uses: actions/setup-python@v2 |
| 16 | + with: |
| 17 | + python-version: "3.12" |
| 18 | + - name: Cache virtualenv |
| 19 | + id: venv-cache |
| 20 | + uses: actions/cache@v3 |
| 21 | + with: |
| 22 | + path: .venv |
| 23 | + key: venv-${{ runner.os }}-${{ github.job }}-${{ github.ref }}-3.12 |
| 24 | + restore-keys: | |
| 25 | + venv-${{ runner.os }}-${{ github.job }}-${{ github.ref }}- |
| 26 | + venv-${{ runner.os }}-${{ github.job }}- |
| 27 | + venv-${{ runner.os }}- |
| 28 | + - name: Install Poetry |
| 29 | + run: python -m pip install poetry |
| 30 | + - name: Cache Poetry and pip |
| 31 | + uses: actions/cache@v3 |
| 32 | + with: |
| 33 | + path: | |
| 34 | + ~/.cache/pypoetry |
| 35 | + ~/.cache/pip |
| 36 | + key: poetry-pip-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} |
| 37 | + restore-keys: | |
| 38 | + poetry-pip-${{ runner.os }}- |
| 39 | + - name: Install Dependencies with Poetry |
| 40 | + run: poetry install --no-interaction --no-ansi |
| 41 | + - name: Build Documentation |
| 42 | + run: | |
| 43 | + poetry run make build-docs |
| 44 | + - name: Install AWS CLI |
| 45 | + run: | |
| 46 | + sudo apt update |
| 47 | + sudo apt install -y awscli |
| 48 | + - name: Configure AWS CLI for Cloudflare R2 |
| 49 | + run: | |
| 50 | + aws configure set aws_access_key_id ${{ secrets.CF_R2_ACCESS_KEY_ID }} |
| 51 | + aws configure set aws_secret_access_key ${{ secrets.CF_R2_SECRET_ACCESS_KEY }} |
| 52 | + aws configure set default.region us-east-1 # R2 uses us-east-1 by default |
| 53 | + aws configure set default.output json |
| 54 | + - name: Sync to Cloudflare R2 |
| 55 | + env: |
| 56 | + CF_R2_ENDPOINT: ${{ secrets.CF_R2_ENDPOINT }} |
| 57 | + CF_R2_BUCKET_NAME: ${{ secrets.CF_R2_BUCKET_NAME }} |
| 58 | + run: | |
| 59 | + aws s3 sync docs/build/en/html s3://$CF_R2_BUCKET_NAME/en/ \ |
| 60 | + --delete \ |
| 61 | + --acl public-read \ |
| 62 | + --endpoint-url $CF_R2_ENDPOINT |
| 63 | + aws s3 sync docs/build/ru/html s3://$CF_R2_BUCKET_NAME/ru/ \ |
| 64 | + --delete \ |
| 65 | + --acl public-read \ |
| 66 | + --endpoint-url $CF_R2_ENDPOINT |
0 commit comments