From b2d876cda2ea780545968ca517d942f3ea6af530 Mon Sep 17 00:00:00 2001 From: thenav56 Date: Fri, 2 Feb 2024 10:55:17 +0545 Subject: [PATCH] Test commit --- .github/actions/run_build/action.yml | 75 +++++++++++++++++++++++++ .github/workflows/aws_deploy.yml | 18 ++++-- .github/workflows/ci.yml | 84 +++++++++------------------- .github/workflows/run_build.yml | 68 ---------------------- 4 files changed, 113 insertions(+), 132 deletions(-) create mode 100644 .github/actions/run_build/action.yml delete mode 100644 .github/workflows/run_build.yml diff --git a/.github/actions/run_build/action.yml b/.github/actions/run_build/action.yml new file mode 100644 index 00000000..0215a642 --- /dev/null +++ b/.github/actions/run_build/action.yml @@ -0,0 +1,75 @@ +name: React Build +description: 'Reusable workflow for building idmc website components' + +inputs: + # Required + REACT_APP_ENVIRONMENT: + description: '' + required: true + BUILD_OUTPUT_DIR: + description: '' + required: true + UPLOAD_ARTIFACT_NAME: + description: '' + required: true + # Optional + # -- Helix + REACT_APP_HELIX_GRAPHQL_ENDPOINT: + description: '' + required: false + default: https://helix-tools-api.idmcdb.org/graphql + REACT_APP_HELIX_REST_ENDPOINT: + description: '' + required: false + default: https://helix-tools-api.idmcdb.org/external-api/ + # -- IDMC Website + REACT_APP_GIDD_GRAPHQL_ENDPOINT: + description: '' + required: false + default: https://website-api.idmcdb.org/graphql/ + REACT_APP_DRUPAL_ENDPOINT: + description: '' + required: false + default: https://www.internal-displacement.org + # -- Misc + REACT_APP_DATA_RELEASE: + description: '' + required: false + default: RELEASE + +runs: + using: "composite" + steps: + - name: 🤞 Run Build 🧪 + env: + # Unsed variables + GIDD_GRAPHQL_CODEGEN_ENDPOINT: '' + HELIX_GRAPHQL_CODEGEN_ENDPOINT: '' + REACT_APP_GA_TRACKING_ID: '' + # Common + # TODO: is this required here? + REACT_APP_HELIX_CLIENT_ID: IDMCWSHSOLO009 + REACT_APP_MAPBOX_ACCESS_TOKEN: pk.eyJ1IjoidG9nZ2xlY29ycCIsImEiOiJjazk5ZXMza2YxZmQ1M2dvNWxneTEycnQwIn0.K3u-ns63rFzM7CzrnOBm2w + REACT_APP_MAPBOX_STYLE: mapbox://styles/togglecorp/cl50rwy0a002d14mo6w9zprio + REACT_APP_HCAPTCHA_SITEKEY: c81616ab-e71b-466a-a03a-650b2472fb34 + REACT_APP_TINY_MCE_KEY: o65ezg70uejj1ibo2janhtw6n1eiii7fm2w2yanfnvqe6ipa + REACT_APP_SENTRY_DSN: https://5e568ceb82d94590879272b6644f86ea@o479248.ingest.sentry.io/6409048 + # Default values + # -- Helix + REACT_APP_HELIX_GRAPHQL_ENDPOINT: ${{ inputs.REACT_APP_HELIX_GRAPHQL_ENDPOINT }} + REACT_APP_HELIX_REST_ENDPOINT: ${{ inputs.REACT_APP_HELIX_REST_ENDPOINT }} + # -- IDMC Website + REACT_APP_GIDD_GRAPHQL_ENDPOINT: ${{ inputs.REACT_APP_GIDD_GRAPHQL_ENDPOINT }} + REACT_APP_DRUPAL_ENDPOINT: ${{ inputs.REACT_APP_DRUPAL_ENDPOINT }} + # -- Misc + REACT_APP_DATA_RELEASE: ${{ inputs.REACT_APP_DATA_RELEASE }} + REACT_APP_ENVIRONMENT: ${{ inputs.REACT_APP_ENVIRONMENT }} + BUILD_OUTPUT_DIR: ${{ inputs.BUILD_OUTPUT_DIR }} + shell: bash + run: env && env > .env && yarn build && mv build/ $BUILD_OUTPUT_DIR + + - name: Save build files as artifact (PREVIEW -> Helix-STAGING) + uses: actions/upload-artifact@v1 + with: + name: ${{ inputs.UPLOAD_ARTIFACT_NAME }} + path: ${{ inputs.BUILD_OUTPUT_DIR }} diff --git a/.github/workflows/aws_deploy.yml b/.github/workflows/aws_deploy.yml index e281fdcc..16957bfc 100644 --- a/.github/workflows/aws_deploy.yml +++ b/.github/workflows/aws_deploy.yml @@ -3,13 +3,16 @@ name: Reusable workflow for deploying idmc website components on: workflow_call: inputs: - ARTIFACT_NAME: + GH_ENVIRONMENT_NAME: required: true type: string - S3_BUCKET: + GH_ENVIRONMENT_URL: required: true type: string - DISTRIBUTION: + ARTIFACT_NAME: + required: true + type: string + S3_BUCKET: required: true type: string @@ -18,6 +21,10 @@ jobs: name: Deploy runs-on: ubuntu-latest + environment: + name: ${{ inputs.GH_ENVIRONMENT_NAME }} + url: ${{ inputs.GH_ENVIRONMENT_URL }} + steps: - uses: actions/download-artifact@v1 with: @@ -35,11 +42,12 @@ jobs: - name: S3 Sync env: AWS_S3_BUCKET: ${{ inputs.S3_BUCKET }} - run: aws s3 cp --follow-symlinks --delete ./build $AWS_S3_BUCKET + # run: aws s3 cp --follow-symlinks --delete ./build $AWS_S3_BUCKET + run: aws s3 ls $AWS_S3_BUCKET # Invalidate Cloudfront - name: Cloudfront Invalidate uses: chetan/invalidate-cloudfront-action@master env: - DISTRIBUTION: ${{ inputs.DISTRIBUTION }} + DISTRIBUTION: ${{ secrets.AWS_DISTRIBUTION }} PATHS: '/*' diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f5fc36d4..3f7a56fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,10 +1,10 @@ name: CI on: - pull_request: push: branches: - release + - feature/new-staging-prod-deployment-pipeline permissions: id-token: write # This is required for requesting the JWT @@ -48,10 +48,11 @@ jobs: run: yarn install --frozen-lockfile --prefer-offline - name: 🤞 Run Build 🧪 (PREVIEW -> Helix-STAGING) - uses: ./.github/workflows/run_build.yml + uses: ./.github/actions/run_build with: REACT_APP_ENVIRONMENT: preview BUILD_OUTPUT_DIR: build-preview-helix-staging/ + UPLOAD_ARTIFACT_NAME: helix-staging-preview-idmc-website-components # Overwrite REACT_APP_DATA_RELEASE: PRE_RELEASE REACT_APP_DRUPAL_ENDPOINT: https://staging.internal-displacement.org @@ -59,82 +60,47 @@ jobs: REACT_APP_HELIX_REST_ENDPOINT: https://helix-tools-api-staging.idmcdb.org/external-api/ - name: 🤞 Run Build 🧪 (PREVIEW -> Helix-PROD) - uses: ./.github/workflows/run_build.yml + uses: ./.github/actions/run_build with: REACT_APP_ENVIRONMENT: preview BUILD_OUTPUT_DIR: build-preview/ + UPLOAD_ARTIFACT_NAME: preview-idmc-website-components # Overwrite REACT_APP_DATA_RELEASE: PRE_RELEASE REACT_APP_DRUPAL_ENDPOINT: https://staging.internal-displacement.org - name: 🤞 Run Build 🧪 (RELEASE/PROD) - uses: ./.github/workflows/run_build.yml + uses: ./.github/actions/run_build with: REACT_APP_ENVIRONMENT: release BUILD_OUTPUT_DIR: build-release/ - - - name: Save build files as artifact (PREVIEW -> Helix-STAGING) - uses: actions/upload-artifact@v1 - with: - name: helix-staging-preview-idmc-website-components - path: build-preview-helix-staging/ - - - name: Save build files as artifact (PREVIEW -> Helix-PROD) - uses: actions/upload-artifact@v1 - with: - name: preview-idmc-website-components - path: build-preview/ - - - name: Save build files as artifact (RELEASE/PROD) - uses: actions/upload-artifact@v1 - with: - name: release-idmc-website-components - path: build-release/ + UPLOAD_ARTIFACT_NAME: release-idmc-website-components helix_staging_preview_deploy: name: Deploy (PREVIEW -> Helix-STAGING) needs: run_build - runs-on: ubuntu-latest - - environment: - name: preview - url: https://preview-website-components.idmcdb.org - - steps: - - uses: ./.github/workflows/aws_deploy.yml - with: - ARTIFACT_NAME: helix-staging-preview-idmc-website-components - S3_BUCKET: ${{ secrets.PREVIEW_AWS_S3_BUCKET }} - DISTRIBUTION: ${{ secrets.PREVIEW_AWS_CLOUDFRONT_DISTRIBUTION }} + uses: ./.github/workflows/aws_deploy.yml + with: + GH_ENVIRONMENT_NAME: preview + GH_ENVIRONMENT_URL: https://preview-website-components.idmcdb.org + ARTIFACT_NAME: helix-staging-preview-idmc-website-components + S3_BUCKET: idmc-website-components-preview preview_deploy: name: Deploy (PREVIEW -> Helix-PROD) needs: helix_staging_preview_deploy - runs-on: ubuntu-latest - - environment: - name: preview - url: https://preview-website-components.idmcdb.org - - steps: - - uses: ./.github/workflows/aws_deploy.yml - with: - ARTIFACT_NAME: preview-idmc-website-components - S3_BUCKET: ${{ secrets.PREVIEW_AWS_S3_BUCKET }} - DISTRIBUTION: ${{ secrets.PREVIEW_AWS_CLOUDFRONT_DISTRIBUTION }} + uses: ./.github/workflows/aws_deploy.yml + with: + GH_ENVIRONMENT_NAME: preview + GH_ENVIRONMENT_URL: https://preview-website-components.idmcdb.org + ARTIFACT_NAME: preview-idmc-website-components + S3_BUCKET: idmc-website-components-preview release_deploy: name: Deploy (Release/Prod) - needs: preview_deploy - runs-on: ubuntu-latest - - environment: - name: release - url: https://release-website-components.idmcdb.org - - steps: - - uses: ./.github/workflows/aws_deploy.yml - with: - ARTIFACT_NAME: release-idmc-website-components - S3_BUCKET: ${{ secrets.RELEASE_AWS_S3_BUCKET }} - DISTRIBUTION: ${{ secrets.RELEASE_AWS_CLOUDFRONT_DISTRIBUTION }} + uses: ./.github/workflows/aws_deploy.yml + with: + GH_ENVIRONMENT_NAME: release + GH_ENVIRONMENT_URL: https://release-website-components.idmcdb.org + ARTIFACT_NAME: release-idmc-website-components + S3_BUCKET: idmc-website-components-release diff --git a/.github/workflows/run_build.yml b/.github/workflows/run_build.yml deleted file mode 100644 index b05c208a..00000000 --- a/.github/workflows/run_build.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Reusable workflow for building idmc website components - -on: - workflow_call: - inputs: - # Required - REACT_APP_ENVIRONMENT: - required: true - type: string - BUILD_OUTPUT_DIR: - required: true - type: string - # Optional - # -- Helix - REACT_APP_HELIX_GRAPHQL_ENDPOINT: - required: false - type: string - default: https://helix-tools-api.idmcdb.org/graphql - REACT_APP_HELIX_REST_ENDPOINT: - required: false - type: string - default: https://helix-tools-api.idmcdb.org/external-api/ - # -- IDMC Website - REACT_APP_GIDD_GRAPHQL_ENDPOINT: - required: false - type: string - default: https://website-api.idmcdb.org/graphql/ - REACT_APP_DRUPAL_ENDPOINT: - required: false - type: string - default: https://www.internal-displacement.org - # -- Misc - REACT_APP_DATA_RELEASE: - required: false - type: string - default: RELEASE - -jobs: - build: - name: Build - runs-on: ubuntu-latest - steps: - - name: 🤞 Run Build 🧪 - env: - # Unsed variables - GIDD_GRAPHQL_CODEGEN_ENDPOINT: '' - HELIX_GRAPHQL_CODEGEN_ENDPOINT: '' - REACT_APP_GA_TRACKING_ID: '' - # Common - # TODO: is this required here? - REACT_APP_HELIX_CLIENT_ID: IDMCWSHSOLO009 - REACT_APP_MAPBOX_ACCESS_TOKEN: pk.eyJ1IjoidG9nZ2xlY29ycCIsImEiOiJjazk5ZXMza2YxZmQ1M2dvNWxneTEycnQwIn0.K3u-ns63rFzM7CzrnOBm2w - REACT_APP_MAPBOX_STYLE: mapbox://styles/togglecorp/cl50rwy0a002d14mo6w9zprio - REACT_APP_HCAPTCHA_SITEKEY: c81616ab-e71b-466a-a03a-650b2472fb34 - REACT_APP_TINY_MCE_KEY: o65ezg70uejj1ibo2janhtw6n1eiii7fm2w2yanfnvqe6ipa - REACT_APP_SENTRY_DSN: https://5e568ceb82d94590879272b6644f86ea@o479248.ingest.sentry.io/6409048 - # Default values - # -- Helix - REACT_APP_HELIX_GRAPHQL_ENDPOINT: ${{ inputs.REACT_APP_HELIX_GRAPHQL_ENDPOINT }} - REACT_APP_HELIX_REST_ENDPOINT: ${{ inputs.REACT_APP_HELIX_REST_ENDPOINT }} - # -- IDMC Website - REACT_APP_GIDD_GRAPHQL_ENDPOINT: ${{ inputs.REACT_APP_GIDD_GRAPHQL_ENDPOINT }} - REACT_APP_DRUPAL_ENDPOINT: ${{ inputs.REACT_APP_DRUPAL_ENDPOINT }} - # -- Misc - REACT_APP_DATA_RELEASE: ${{ inputs.REACT_APP_DATA_RELEASE }} - REACT_APP_ENVIRONMENT: ${{ inputs.REACT_APP_ENVIRONMENT }} - BUILD_OUTPUT_DIR: ${{ inputs.BUILD_OUTPUT_DIR }} - run: env > .env && yarn build && mv build/ $BUILD_OUTPUT_DIR