Skip to content

Commit

Permalink
use env for release and refactor to one file
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jul 20, 2024
1 parent 2ab1c58 commit 2c47d58
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 107 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/deploy-prod-mainnet-devhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
49 changes: 0 additions & 49 deletions .github/workflows/deploy-prod-mainnet-events.yml

This file was deleted.

49 changes: 0 additions & 49 deletions .github/workflows/deploy-prod-mainnet-infra.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/release-instances.yml
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 2c47d58

Please sign in to comment.