Deploy of stage to STAGE #1785
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: Docs deploy | |
| run-name: Deploy of ${{ github.ref_name }} to ${{github.event.inputs.environment}} | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| type: choice | |
| description: Target | |
| required: true | |
| options: | |
| - STAGE # www-stage.ankr.com/docs/ | |
| - BS1 # bs-1-stage.dccn.ankr.com/docs/ | |
| - BS2 # bs-2-stage.dccn.ankr.com/docs/ | |
| - BS3 # bs-3-stage.dccn.ankr.com/docs/ | |
| - BS4 # bs-4-stage.dccn.ankr.com/docs/ | |
| - PROD # www.ankr.com/docs/ | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }}-docs | |
| cancel-in-progress: true | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| - name: Prevent wrong version releasing | |
| if: ${{ github.event.inputs.environment == 'PROD' && github.ref != 'refs/heads/main' }} | |
| run: | | |
| echo "Production deployment is possible only from the main branch" | |
| exit 1 | |
| - name: Build | |
| if: ${{ github.event.inputs.environment == 'PROD' }} | |
| working-directory: . | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=12288" | |
| run: | | |
| yarn install | |
| yarn build | |
| - name: Build stage | |
| if: ${{ github.event.inputs.environment != 'PROD' }} | |
| working-directory: . | |
| env: | |
| NODE_OPTIONS: "--max-old-space-size=12288" | |
| run: | | |
| yarn install | |
| yarn build:stage | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: main | |
| repository: Ankr-network/staking-frontend | |
| token: ${{ secrets.ACCESS_TOKEN }} | |
| path: staking-frontend | |
| - name: Install dependencies and build doc sdk | |
| run: | | |
| yarn --cwd staking-frontend/packages/staking-sdk | |
| cd staking-frontend/packages/staking-sdk | |
| yarn docs | |
| - name: Copy build | |
| run: | | |
| cd out/staking-for-developers/sdk/ | |
| mkdir liquid-staking | |
| cd liquid-staking | |
| mkdir reference | |
| cd ../../../../ | |
| mv staking-frontend/packages/staking-sdk/docs/* out/staking-for-developers/sdk/liquid-staking/reference | |
| - name: Set AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Copy files to the production website with the AWS CLI | |
| working-directory: . | |
| env: | |
| DOMAIN: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DOMAIN')] }} | |
| DISTRIBUTION_ID: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DISTRIBUTION_ID')] }} | |
| run: | | |
| aws s3 sync --delete ./out s3://$DOMAIN/docs/ --acl public-read --cache-control "public,max-age=600,s-maxage=3600" | |
| aws configure set preview.cloudfront true | |
| echo "Invalidating CDN network" | |
| INVALIDATION_ID=`aws cloudfront create-invalidation --distribution-id $DISTRIBUTION_ID --paths '/*' | jq -r '.Invalidation.Id'` | |
| echo "Invalidation ID is $INVALIDATION_ID" | |
| echo "CDN Invalidation request is sent." | |
| - name: Set redirections | |
| working-directory: . | |
| env: | |
| DOMAIN: ${{ vars[format('{0}{1}', github.event.inputs.environment, '_DOMAIN')] }} | |
| run: | | |
| node redirects.js |