From 37faef1e7462dfeef07f220ec8d7695dd64c789e Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 6 Dec 2024 01:11:09 +0100 Subject: [PATCH 1/3] Upload build preview site as artifacts --- .github/workflows/website-deploy-preview.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/website-deploy-preview.yml b/.github/workflows/website-deploy-preview.yml index 3f9fae4ce..04465857d 100644 --- a/.github/workflows/website-deploy-preview.yml +++ b/.github/workflows/website-deploy-preview.yml @@ -63,6 +63,14 @@ jobs: npm install --only=production npm run build:site + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: website + path: website/build + if-no-files-found: error + retention-days: 1 + - name: Copy Website to S3 Bucket PR Folder run: | cd website/build From 90ca6fb1f81be5cd625110980e2c214eb57a4c30 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 6 Dec 2024 03:19:17 +0300 Subject: [PATCH 2/3] Update README.md --- website/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/website/README.md b/website/README.md index f01949b54..a584592e2 100644 --- a/website/README.md +++ b/website/README.md @@ -11,3 +11,5 @@ This folder contains the website powering official [Atmos](https://atmos.tools) 4. Start the local web server by running `npm run start` The shortcut for running all these commands is just to run `make all` + + From e08dcb8d76a119e9a0c2e8e4e086d0ce9cd23311 Mon Sep 17 00:00:00 2001 From: Igor Rodionov Date: Fri, 6 Dec 2024 01:42:43 +0100 Subject: [PATCH 3/3] Added new deploy workflow --- .github/workflows/deploy-preview.yml | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 000000000..4e998ad2b --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,61 @@ +name: "Deploy Preview" + +on: + workflow_run: + workflows: [Website Deploy Preview] + types: + - completed + +env: + AWS_REGION: us-east-2 + IAM_ROLE_ARN: arn:aws:iam::068007702576:role/cplive-plat-ue2-dev-atmos-docs-gha + IAM_ROLE_SESSION_NAME: cloudposse-atmos-ci-deploy-pr-${{ github.event.workflow_run.pull_requests.0.number }} + S3_BUCKET_NAME: cplive-plat-ue2-dev-atmos-docs-origin + PR_NUMBER: ${{ github.event.workflow_run.pull_requests.0.number }} + DEPLOYMENT_HOST: pr-${{ github.event.workflow_run.pull_requests.0.number }}.atmos-docs.ue2.dev.plat.cloudposse.org + ALGOLIA_INDEX_NAME: atmos-preview.tools + ALGOLIA_APP_ID: 32YOERUX83 + +# These permissions are needed to interact with the GitHub's OIDC Token endpoint +permissions: + id-token: write + contents: read + +jobs: + website-deploy-preview: + # Do not deploy the website to the preview environment if the PR has the label 'website-no-deploy' or the workflow run failed + if: ${{ github.event.workflow_run.conclusion == 'success' && !contains(github.event.workflow_run.pull_requests.*.labels.*.name, 'website-no-deploy') }} + runs-on: ubuntu-latest + environment: + name: preview + url: https://${{ env.DEPLOYMENT_HOST }} + + steps: + # https://github.com/marketplace/actions/configure-aws-credentials-action-for-github-actions + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-region: ${{ env.AWS_REGION }} + role-to-assume: ${{ env.IAM_ROLE_ARN }} + role-session-name: ${{ env.IAM_ROLE_SESSION_NAME }} + + - name: Download artifacts + uses: actions/download-artifact@v4 + with: + name: website + path: website/build + run-id: ${{ github.event.workflow_run.id }} + + - name: Copy Website to S3 Bucket PR Folder + run: | + cd website/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.workflow_run.pull_requests.*.labels.*.name, 'reindex') }} + env: + ALGOLIA_SCRAPER_API_KEY: ${{ secrets.ALGOLIA_SCRAPER_API_KEY }} + run: | + ./website/algolia/reindex.sh