From e390e6e95d068bed584a86f235479dc32062a624 Mon Sep 17 00:00:00 2001 From: milldr Date: Fri, 7 Jun 2024 11:32:57 -0700 Subject: [PATCH] created staging release pipelines --- .../website-deploy-staging-preview.yml | 2 +- .../website-deploy-staging-release.yml | 83 ++++--------------- 2 files changed, 15 insertions(+), 70 deletions(-) diff --git a/.github/workflows/website-deploy-staging-preview.yml b/.github/workflows/website-deploy-staging-preview.yml index 7e7196ddd..ccd2aa91b 100644 --- a/.github/workflows/website-deploy-staging-preview.yml +++ b/.github/workflows/website-deploy-staging-preview.yml @@ -96,7 +96,7 @@ jobs: GOOGLE_SITE_VERIFICATION_ID: ${{ env.GOOGLE_SITE_VERIFICATION_ID }} run: | make init - make build-production + make build-staging - name: Copy Website to S3 Bucket PR Folder run: | diff --git a/.github/workflows/website-deploy-staging-release.yml b/.github/workflows/website-deploy-staging-release.yml index c1f0be04a..534647d8a 100644 --- a/.github/workflows/website-deploy-staging-release.yml +++ b/.github/workflows/website-deploy-staging-release.yml @@ -34,29 +34,29 @@ jobs: steps: # https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 + uses: aws-actions/configure-aws-credentials@v1 with: aws-region: ${{ env.AWS_REGION }} role-to-assume: ${{ env.IAM_ROLE_ARN }} role-session-name: ${{ env.IAM_ROLE_SESSION_NAME }} - name: Checkout Repository - uses: actions/checkout@v4 + uses: actions/checkout@v3 with: fetch-depth: 0 - - name: "Checkout 'cloudposse/docs' Repository" - uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v3 with: - fetch-depth: 1 - repository: cloudposse/docs - ref: master - path: cloudposse-docs + node-version-file: ".nvmrc" - - name: Setup Node - uses: actions/setup-node@v4 + - name: "Checkout 'terraform-aws-components' Repository" + uses: actions/checkout@v3 with: - node-version-file: "cloudposse-docs/.nvmrc" + fetch-depth: 1 + repository: cloudposse/terraform-aws-components + ref: main + path: tmp/components/terraform-aws-components - name: "Setup Python" uses: actions/setup-python@v4 @@ -66,90 +66,35 @@ jobs: - name: "Install Python Dependencies" run: | make init - pip install -r cloudposse-docs/scripts/docs-collator/requirements.txt - - - name: "Install awscli" - run: | - sudo apt-get update && \ - sudo apt-get install -y --no-install-recommends awscli - - - name: "Checkout 'terraform-aws-components' Repository" - uses: actions/checkout@v4 - with: - fetch-depth: 1 - repository: cloudposse/terraform-aws-components - ref: main - path: cloudposse-docs/tmp/components/terraform-aws-components + pip install -r scripts/docs-collator/requirements.txt - name: "Render Documentation for Terraform Components" run: | - cd cloudposse-docs ./scripts/render-docs-for-components.sh - name: "Render Documentation for Terraform Modules" env: PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} run: | - cd cloudposse-docs ./scripts/render-docs-for-modules.sh - name: "Render Documentation for GitHub Actions" env: PUBLIC_REPO_ACCESS_TOKEN: ${{ secrets.REPO_ACCESS_TOKEN }} run: | - cd cloudposse-docs ./scripts/render-docs-for-github-actions.sh - - name: "Pre Rendering Processing" - run: | - make init - make build - ./docs/scripts/prepare-static-docs-for-rendering.sh - ./docs/scripts/prepare-scaffolding-docs-for-rendering.sh - - name: Install Dependencies and Build Website env: GOOGLE_TAG_MANAGER: ${{ env.GOOGLE_TAG_MANAGER }} GOOGLE_SITE_VERIFICATION_ID: ${{ env.GOOGLE_SITE_VERIFICATION_ID }} run: | - cd cloudposse-docs/ make init make build-staging - - name: "Post Rendering Processing" - run: | - ./docs/scripts/split-sitemap.sh - - # "assets/refarch/handoffs/*" are handled by cloudposse-corp/demos - name: Copy Website to S3 Bucket run: | - cd cloudposse-docs/build/ + cd build aws sts get-caller-identity - aws s3 sync . s3://${{ env.S3_BUCKET_NAME }} --delete --exclude "assets/refarch/handoffs/*" + aws s3 sync . s3://${{ env.S3_BUCKET_NAME }} --delete --exclude "pr-*" aws s3 ls s3://${{ env.S3_BUCKET_NAME }}/ --recursive --human-readable --summarize - - - name: Invalidate cache for Cloudfront - run: | - echo "Sending invalidation request" - invalidation_id=$(aws cloudfront create-invalidation \ - --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \ - --paths "/*" \ - --output json | jq -r '.Invalidation.Id') - - echo "Waiting for invalidation to complete..." - aws cloudfront wait invalidation-completed \ - --id $invalidation_id \ - --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} - - echo "done." - - - name: Invalidate cache for Cloudflare - run: | - curl -v -X POST \ - -d '{"purge_everything": true}' \ - --header 'Content-Type: application/json' \ - --header "Authorization: Bearer ${{ secrets.CLOUDFLARE_CACHE_PURGE_API_KEY }}" \ - "https://api.cloudflare.com/client/v4/zones/${{ vars.CLOUDFLARE_CLOUDPOSSE_COM_ZONE_ID }}/purge_cache" - - # Sleep after sending request to give some time before Algolia Index triggers - sleep 30s