diff --git a/.github/workflows/deploy-prod-mainnet-devhub.yml b/.github/workflows/deploy-prod-mainnet-devhub.yml index 5dc31fee3..e5f35851b 100644 --- a/.github/workflows/deploy-prod-mainnet-devhub.yml +++ b/.github/workflows/deploy-prod-mainnet-devhub.yml @@ -7,12 +7,7 @@ jobs: deploy-widgets: runs-on: ubuntu-latest name: Deploy ( or diff from PR ) - Devhub - env: - NEAR_SOCIAL_DEPLOY_ID: ${{ vars.NEAR_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_ID: ${{ vars.NEAR_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY }} - NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY }} - POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} + environment: devhub.near defaults: run: working-directory: ./instances/devhub.near @@ -23,7 +18,7 @@ jobs: - name: Set replacements id: set_replacements run: | - echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'$POSTHOG_API_KEY'"}]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT + echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'${{ secrets.POSTHOG_API_KEY }}'"}]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT - name: Replace placeholders uses: flcdrg/replace-multiple-action@v1 @@ -43,7 +38,7 @@ jobs: echo "on branch $BRANCH" if [[ "$BRANCH" != "main" ]]; then echo "Not on main branch, dry run by diff with devhub.near" - bos components diff devhub.near network-config mainnet + npm run dry-run:devhub else - bos components deploy "$NEAR_SOCIAL_DEPLOY_ID" sign-as "$NEAR_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY" send + bos components deploy '${{ vars.NEAR_SOCIAL_ACCOUNT_ID }}' sign-as '${{ vars.NEAR_SOCIAL_ACCOUNT_ID }}' network-config mainnet sign-with-plaintext-private-key --signer-public-key '${{ vars.NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY }}' --signer-private-key '${{ secrets.NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY }}' send fi diff --git a/.github/workflows/deploy-prod-mainnet-events.yml b/.github/workflows/deploy-prod-mainnet-events.yml deleted file mode 100644 index bb239966f..000000000 --- a/.github/workflows/deploy-prod-mainnet-events.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Deploy Widgets to Mainnet - Events Committee -on: - pull_request: - push: - branches: [main] -jobs: - deploy-widgets: - runs-on: ubuntu-latest - name: Deploy ( or diff from PR ) - Events - env: - NEAR_SOCIAL_DEPLOY_ID: ${{ vars.NEAR_EVENTS_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_ID: ${{ vars.NEAR_EVENTS_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_EVENTS_SOCIAL_ACCOUNT_PUBLIC_KEY }} - NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_EVENTS_SOCIAL_ACCOUNT_PRIVATE_KEY }} - POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - defaults: - run: - working-directory: ./instances/events-committee.near - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set replacements - id: set_replacements - run: | - echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'$POSTHOG_API_KEY'"}]' aliases.mainnet.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 bos CLI - run: | - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh - - - name: Deploy widgets - run: | - BRANCH="$(git rev-parse --abbrev-ref HEAD)" - echo "on branch $BRANCH" - if [[ "$BRANCH" != "main" ]]; then - echo "Not on main branch, dry run by diff with events-committee.near" - bos components diff events-committee.near network-config mainnet - else - bos components deploy "$NEAR_EVENTS_SOCIAL_DEPLOY_ID" sign-as "$NEAR_EVENTS_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_EVENTS_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_EVENTS_SOCIAL_ACCOUNT_PRIVATE_KEY" send - fi diff --git a/.github/workflows/deploy-prod-mainnet-infra.yml b/.github/workflows/deploy-prod-mainnet-infra.yml deleted file mode 100644 index c19ca87dd..000000000 --- a/.github/workflows/deploy-prod-mainnet-infra.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: Deploy Widgets to Mainnet - Infrastructure -on: - pull_request: - push: - branches: [main] -jobs: - deploy-widgets: - runs-on: ubuntu-latest - name: Deploy ( or diff from PR ) - Infrastructure - env: - NEAR_SOCIAL_DEPLOY_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }} - NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY }} - NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY }} - POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - defaults: - run: - working-directory: ./instances/infrastructure-committee.near - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set replacements - id: set_replacements - run: | - echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'$POSTHOG_API_KEY'"}]' aliases.mainnet.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 bos CLI - run: | - curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh - - - name: Deploy widgets - run: | - BRANCH="$(git rev-parse --abbrev-ref HEAD)" - echo "on branch $BRANCH" - if [[ "$BRANCH" != "main" ]]; then - echo "Not on main branch, dry run by diff with infrastructure-committee.near" - bos components diff infrastructure-committee.near network-config mainnet - else - bos components deploy "$NEAR_INFRA_SOCIAL_DEPLOY_ID" sign-as "$NEAR_INFRA_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY" send - fi diff --git a/.github/workflows/release-instances.yml b/.github/workflows/release-instances.yml new file mode 100644 index 000000000..e9ef3cd83 --- /dev/null +++ b/.github/workflows/release-instances.yml @@ -0,0 +1,41 @@ +name: Deploy Components to Mainnet - Events and Infrastructure + +on: + pull_request: + push: + branches: [main] + +jobs: + deploy-widgets: + name: Deploy (or diff from PR) + runs-on: ubuntu-latest + strategy: + matrix: + target_account: + events: + environment: events-committee.near + dry_run_command: npm run dry-run:events + deploy_command: npm run deploy:events + infrastructure: + environment: infrastructure-committee.near + dry_run_command: npm run dry-run:infrastructure + deploy_command: npm run deploy:infrastructure + environment: ${{ matrix.target_account.environment }} + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install bos CLI + run: | + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh + + - name: Deploy widgets + run: | + BRANCH="$(git rev-parse --abbrev-ref HEAD)" + echo "on branch $BRANCH" + if [[ "$BRANCH" != "main" ]]; then + echo "Not on main branch, dry run" + ${matrix.target_account.dry_run_command} + else + ${matrix.target_account.deploy_command} -- '${{ secrets.NEAR_SOCIAL_ACCOUNT_ID }}' sign-as '${{ secrets.NEAR_SOCIAL_ACCOUNT_ID }}' network-config mainnet sign-with-plaintext-private-key --signer-public-key '${{ secrets.NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY }}' --signer-private-key '${{ secrets.NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY }}' send + fi diff --git a/package.json b/package.json index 0d1e4096b..7633001d5 100644 --- a/package.json +++ b/package.json @@ -19,12 +19,17 @@ "bw:dev:devhub": "bw dev instances/devhub.near", "bw:build:devhub": "bw build instances/devhub.near build/devhub.near && mv build/devhub.near/src/widget/* build/devhub.near/src/ && rm -Rf build/devhub.near/src/widget", "gateway:devhub": "node scripts/dev-gateway.mjs devhub.near", + "dry-run:devhub": "npm run bw:build:devhub && cd ./build/devhub.near && bos components diff devhub.near network-config mainnet", "bw:dev:infrastructure": "bw dev instances/infrastructure-committee.near", "bw:build:infrastructure": "bw build instances/infrastructure-committee.near", "gateway:infrastructure": "node scripts/dev-gateway.mjs infrastructure-committee.near", + "deploy:infrastructure": "npm run bw:build:infrastructure && cd ./build/infrastructure.near && bos components deploy", + "dry-run:infrastructure": "npm run bw:build:infrastructure && cd ./build/infrastructure-committee.near && bos components diff infrastructure-committee.near network-config mainnet", "bw:dev:events": "bw dev instances/events-committee.near", "bw:build:events": "bw build instances/events-committee.near", "gateway:events": "node scripts/dev-gateway.mjs events-committee.near", + "deploy:events": "npm run bw:build:events && cd ./build/events-committee.near && bos components deploy", + "dry-run:events": "npm run bw:build:events && cd ./build/events-committee.near && bos components diff events-committee.near network-config mainnet", "test": "npx playwright test", "test:devhub": "INSTANCE=devhub npx playwright test --project=devhub --ui", "test:events": "INSTANCE=events npx playwright test --project=events --ui",