Skip to content

Commit

Permalink
Test commit
Browse files Browse the repository at this point in the history
  • Loading branch information
thenav56 committed Feb 2, 2024
1 parent 1eef79f commit 0b73ad3
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 128 deletions.
75 changes: 75 additions & 0 deletions .github/actions/run_build/action.yml
Original file line number Diff line number Diff line change
@@ -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://[email protected]/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 }}
13 changes: 12 additions & 1 deletion .github/workflows/aws_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ name: Reusable workflow for deploying idmc website components
on:
workflow_call:
inputs:
GH_ENVIRONMENT_NAME:
required: true
type: string
GH_ENVIRONMENT_URL:
required: true
type: string
ARTIFACT_NAME:
required: true
type: string
Expand All @@ -18,6 +24,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:
Expand All @@ -35,7 +45,8 @@ 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
Expand Down
87 changes: 28 additions & 59 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,93 +48,62 @@ 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
REACT_APP_HELIX_GRAPHQL_ENDPOINT: https://helix-tools-api-staging.idmcdb.org/graphql
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: ${{ secrets.PREVIEW_AWS_S3_BUCKET }}
DISTRIBUTION: ${{ secrets.PREVIEW_AWS_CLOUDFRONT_DISTRIBUTION }}

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: ${{ secrets.PREVIEW_AWS_S3_BUCKET }}
DISTRIBUTION: ${{ secrets.PREVIEW_AWS_CLOUDFRONT_DISTRIBUTION }}

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: ${{ secrets.RELEASE_AWS_S3_BUCKET }}
DISTRIBUTION: ${{ secrets.RELEASE_AWS_CLOUDFRONT_DISTRIBUTION }}
68 changes: 0 additions & 68 deletions .github/workflows/run_build.yml

This file was deleted.

0 comments on commit 0b73ad3

Please sign in to comment.