From b613364e825400002471f0be68af9cff15c35eb8 Mon Sep 17 00:00:00 2001 From: Roshaan Siddiqui Date: Wed, 16 Aug 2023 07:55:24 -0500 Subject: [PATCH] feat: update widgets ci/cd --- .github/workflows/deploy-dev-widgets.yml | 3 ++- .github/workflows/deploy-prod-widgets.yml | 1 + .github/workflows/deploy-widgets.yml | 25 ++++++++++++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deploy-dev-widgets.yml b/.github/workflows/deploy-dev-widgets.yml index 5d0327275..94b80c8d4 100644 --- a/.github/workflows/deploy-dev-widgets.yml +++ b/.github/workflows/deploy-dev-widgets.yml @@ -1,7 +1,7 @@ name: Deploy Dev Components to Mainnet on: push: - branches: [main] + branches: [feat/use-replacement-maps] paths: - "frontend/widgets/**" jobs: @@ -11,5 +11,6 @@ jobs: directory-paths: ${{vars.WIDGETS_DIRECTORY_PATHS}} deploy-account-address: ${{ vars.DEV_SIGNER_ACCOUNT_ID }} signer-public-key: ${{ vars.DEV_SIGNER_PUBLIC_KEY }} + environment: dev secrets: SIGNER_PRIVATE_KEY: ${{ secrets.DEV_SIGNER_PRIVATE_KEY }} diff --git a/.github/workflows/deploy-prod-widgets.yml b/.github/workflows/deploy-prod-widgets.yml index d847626bd..9bdbdcd54 100644 --- a/.github/workflows/deploy-prod-widgets.yml +++ b/.github/workflows/deploy-prod-widgets.yml @@ -11,5 +11,6 @@ jobs: directory-paths: ${{vars.WIDGETS_DIRECTORY_PATHS}} deploy-account-address: ${{ vars.PROD_SIGNER_ACCOUNT_ID }} signer-public-key: ${{ vars.PROD_SIGNER_PUBLIC_KEY }} + environment: mainnet secrets: SIGNER_PRIVATE_KEY: ${{ secrets.PROD_SIGNER_PRIVATE_KEY }} diff --git a/.github/workflows/deploy-widgets.yml b/.github/workflows/deploy-widgets.yml index d57dac082..2ca7f553e 100644 --- a/.github/workflows/deploy-widgets.yml +++ b/.github/workflows/deploy-widgets.yml @@ -1,4 +1,4 @@ -name: Deploy Components to Mainnet +name: Deploy Components on: workflow_call: inputs: @@ -19,6 +19,10 @@ on: required: true description: "Comma-separated paths to the directories that contain the code to be deployed" type: string + environment: + required: true + description: "mainnet or dev" + type: string secrets: SIGNER_PRIVATE_KEY: description: "Private key in `ed25519:` format for signing transaction" @@ -26,17 +30,32 @@ on: jobs: deploy-widgets: runs-on: ubuntu-latest - name: Deploy widgets to social.near (mainnet) + name: Deploy widgets to social.near env: BOS_DEPLOY_ACCOUNT_ID: ${{ inputs.deploy-account-address }} BOS_SIGNER_PUBLIC_KEY: ${{ inputs.signer-public-key }} - BOS_SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} DIRECTORY_PATHS: ${{ inputs.directory-paths }} + ENVIRONMENT: ${{inputs.environment}} + BOS_SIGNER_PRIVATE_KEY: ${{ secrets.SIGNER_PRIVATE_KEY }} steps: - name: Checkout repository uses: actions/checkout@v2 + - name: Set replacements + id: set_replacements + run: | + cd "frontend/widgets/" + echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value)]' ../replacement.${ENVIRONMENT}.json | tr -d "\n\r")" >> $GITHUB_OUTPUT + + - name: Replace placeholders + uses: flcdrg/replace-multiple-action@v1 + with: + files: '**/*.jsx' + find: '${{ steps.set_replacements.outputs.replacements }}' + prefix: '(^|.*)' + suffix: '($|.*)' + - name: Install near-social CLI run: | curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v${{ inputs.cli-version }}/bos-cli-v${{ inputs.cli-version }}-installer.sh | sh