New org components #594
This file contains 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 Preview" | |
on: | |
workflow_dispatch: | |
pull_request_target: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
branches: | |
- 'master' | |
- 'main' | |
env: | |
AWS_REGION: us-east-2 | |
IAM_ROLE_ARN: arn:aws:iam::068007702576:role/cplive-plat-ue2-dev-cloudposse-docs-gha | |
IAM_ROLE_SESSION_NAME: cloudposse-docs-ci-deploy-pr-${{ github.event.pull_request.number }} | |
S3_BUCKET_NAME: cplive-plat-ue2-dev-cloudposse-docs-origin | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
DEPLOYMENT_HOST: pr-${{ github.event.pull_request.number }}.cloudposse-docs.ue2.dev.plat.cloudposse.org | |
ALGOLIA_INDEX_NAME: docs-preview.cloudposse.com | |
ALGOLIA_APP_ID: 32YOERUX83 | |
GOOGLE_TAG_MANAGER: GTM-ABCD123 | |
GOOGLE_SITE_VERIFICATION_ID: preview-github | |
# These permissions are needed to interact with the GitHub's OIDC Token endpoint | |
permissions: | |
id-token: write | |
contents: read | |
concurrency: | |
group: "docs-preview-${{ github.event.pull_request.number }}" | |
cancel-in-progress: true | |
jobs: | |
deploy-preview: | |
runs-on: ubuntu-latest | |
environment: | |
name: preview | |
url: https://${{ env.DEPLOYMENT_HOST }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# This workflows runs on pull_request_target, so we need to checkout the PR branch | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Build Website | |
uses: ./.github/actions/build-website | |
with: | |
aws_region: ${{ env.AWS_REGION }} | |
iam_role_arn: ${{ env.IAM_ROLE_ARN }} | |
iam_role_session_name: ${{ env.IAM_ROLE_SESSION_NAME }} | |
repo_access_token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
- name: Copy Website to S3 Bucket PR Folder | |
run: | | |
cd build | |
aws sts get-caller-identity | |
aws s3 sync . s3://${{ env.S3_BUCKET_NAME }}/pr-${{ env.PR_NUMBER }}/ --delete | |
aws s3 ls s3://${{ env.S3_BUCKET_NAME }}/pr-${{ env.PR_NUMBER }}/ --recursive --human-readable --summarize | |
- name: ReIndex with Algolia | |
if: ${{ contains(github.event.*.labels.*.name, 'reindex') }} | |
env: | |
ALGOLIA_SCRAPER_API_KEY: ${{ secrets.ALGOLIA_SCRAPER_API_KEY }} | |
run: | | |
./algolia/reindex.sh |