|
| 1 | +name: Deploy Redirects |
| 2 | + |
| 3 | +# Publishes redirects/redirects.map to the S3 static-website bucket as per-object 301s |
| 4 | +# (x-amz-website-redirect-location), then invalidates CloudFront. Manual, re-runnable. |
| 5 | +# reference.groupdocs.com = AWS S3 (static-website) + CloudFront; the website endpoint honours |
| 6 | +# per-object redirects. Run QA first and check the verify output before running prod. |
| 7 | +on: |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + environment: |
| 11 | + description: 'Target environment' |
| 12 | + required: true |
| 13 | + default: 'qa' |
| 14 | + type: choice |
| 15 | + options: |
| 16 | + - qa |
| 17 | + - prod |
| 18 | + |
| 19 | +jobs: |
| 20 | + deploy: |
| 21 | + name: Deploy redirects (${{ inputs.environment }}) |
| 22 | + runs-on: ubuntu-latest |
| 23 | + steps: |
| 24 | + - name: Checkout |
| 25 | + uses: actions/checkout@v4 |
| 26 | + |
| 27 | + - name: Resolve environment |
| 28 | + id: cfg |
| 29 | + run: | |
| 30 | + if [ "${{ inputs.environment }}" = "prod" ]; then |
| 31 | + echo "bucket=reference.groupdocs.com" >> $GITHUB_OUTPUT |
| 32 | + echo "verify_base=https://reference.groupdocs.com" >> $GITHUB_OUTPUT |
| 33 | + echo "cf_secret=PROD" >> $GITHUB_OUTPUT |
| 34 | + else |
| 35 | + echo "bucket=reference2.groupdocs.com" >> $GITHUB_OUTPUT |
| 36 | + echo "verify_base=https://reference2.groupdocs.com" >> $GITHUB_OUTPUT |
| 37 | + echo "cf_secret=STAGE" >> $GITHUB_OUTPUT |
| 38 | + fi |
| 39 | +
|
| 40 | + - name: Apply redirects |
| 41 | + env: |
| 42 | + AWS_ACCESS_KEY_ID: ${{ secrets.ACCESS_KEY }} |
| 43 | + AWS_SECRET_ACCESS_KEY: ${{ secrets.SECRET_ACCESS }} |
| 44 | + BUCKET: ${{ steps.cfg.outputs.bucket }} |
| 45 | + REGION: us-west-2 |
| 46 | + VERIFY_BASE: ${{ steps.cfg.outputs.verify_base }} |
| 47 | + CF_DISTRIBUTION: ${{ steps.cfg.outputs.cf_secret == 'PROD' && secrets.AWS_DISTRIBUTION_PROD || secrets.AWS_DISTRIBUTION }} |
| 48 | + run: | |
| 49 | + chmod +x ./scripts/deploy_redirects.sh |
| 50 | + ./scripts/deploy_redirects.sh |
0 commit comments