Deploy OS #206
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy OS | |
on: | |
workflow_dispatch: | |
inputs: | |
network: | |
description: "Network to deploy to" | |
required: true | |
type: string | |
kernel_address: | |
description: "Kernel address" | |
required: false | |
type: string | |
deploy_os: | |
description: "Deploy OS" | |
required: false | |
type: boolean | |
contracts: | |
description: "Contracts to deploy" | |
required: false | |
type: string | |
schema_parser: | |
description: "Schema parser environment" | |
required: false | |
type: choice | |
options: | |
- mainnet | |
- testnet | |
- testnet-staging | |
jobs: | |
build_deploy_script: | |
if: contains('["crnbarr93", "SlayerAnsh", "joemonem", "DimitrijeDragasevic", "cowboy0015"]', github.actor) | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build Deploy Script | |
run: cargo build -p andromeda-deploy --release | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: deploy | |
path: ./target/release/andromeda-deploy | |
if-no-files-found: error | |
build_and_deploy: | |
runs-on: ubuntu-latest | |
needs: [build_deploy_script] | |
env: | |
DEPLOYMENT_CHAIN: ${{ inputs.network }} | |
DEPLOYMENT_KERNEL_ADDRESS: ${{ inputs.kernel_address }} | |
DEPLOY_OS: ${{ inputs.deploy_os }} | |
DEPLOY_CONTRACTS: ${{ inputs.contracts }} | |
SLACK_WEBHOOK_URL: "${{ secrets.DEPLOY_SLACK_WEBHOOK_URL }}" | |
TEST_MNEMONIC: "${{ secrets.DEPLOY_TEST_MNEMONIC }}" | |
RUST_LOG: info | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@v1 | |
with: | |
toolchain: 1.81.0 | |
targets: wasm32-unknown-unknown | |
components: rustfmt, clippy | |
- name: Install Binaryen | |
run: | | |
chmod +x ./scripts/install_binaryen.sh | |
./scripts/install_binaryen.sh | |
- name: Download Deploy Script | |
uses: actions/download-artifact@v4 | |
with: | |
name: deploy | |
path: "./" | |
- name: Deploy | |
run: | | |
chmod +x ./andromeda-deploy | |
./andromeda-deploy | |
- name: Upload Contract Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: contracts | |
path: ./artifacts/ | |
if-no-files-found: error | |
retention-days: 1 | |
- name: Upload Schema Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: temp-schemas | |
path: ./schemas/ | |
if-no-files-found: error | |
retention-days: 1 | |
trigger-schema-parser: | |
needs: [build_and_deploy] | |
runs-on: ubuntu-latest | |
env: | |
ENV: ${{ inputs.schema_parser }} | |
outputs: | |
should_continue: ${{ steps.set-output.outputs.should_continue }} | |
steps: | |
- name: Checkout Schema Parser | |
uses: actions/checkout@v4 | |
with: | |
repository: andromedaprotocol/schema-parser | |
ref: feat/master-schema | |
token: ${{ secrets.CI_PAT }} | |
- name: Download Schemas | |
uses: actions/download-artifact@v4 | |
with: | |
name: temp-schemas | |
path: "packages/schema-parser/schema" | |
- uses: pnpm/action-setup@v4 | |
with: | |
version: 8 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: "18" | |
cache: "pnpm" | |
- name: Process Schema | |
working-directory: packages/schema-parser | |
run: | | |
set -eo pipefail | |
echo "Installing dependencies..." | |
pnpm install | |
echo "Processing schema..." | |
npm run start | |
echo "Flattening schema..." | |
npm run flatten | |
echo "Exporting schema..." | |
npm run export | |
echo "Using ENV variable: $ENV" | |
- name: Commit and Push Changes | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
if [[ -n $(git status --porcelain) ]]; then | |
git add . | |
git commit -m "chore: Update schema for kernel: ${{ inputs.kernel_address }}" | |
git push | |
else | |
echo "No changes to commit" | |
fi | |
- name: Set should_continue output | |
id: set-output | |
run: echo "should_continue=true" >> $GITHUB_OUTPUT | |
trigger-armour-workflow: | |
needs: [trigger-schema-parser] | |
if: needs.trigger-schema-parser.outputs.should_continue == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Wait for schema updates | |
run: | | |
echo "Waiting 6 minutes for schema updates to propagate..." | |
sleep 360 | |
echo "Wait complete, proceeding with Armor workflow trigger" | |
- name: Download version-map | |
uses: actions/download-artifact@v4 | |
with: | |
name: contracts | |
path: "artifacts" | |
- name: Extract version map | |
run: | | |
cd artifacts | |
cat version_map.json | |
cp version_map.json ../version_map.json | |
- name: Trigger Armor Workflow | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.CI_PAT }} | |
script: | | |
const kernelAddress = '${{ inputs.kernel_address }}'; | |
const testnetKernelsList = '${{ vars.TESTNET_KERNELS }}'.split(','); | |
const testnetStagingKernelsList = '${{ vars.TESTNET_STAGING_KERNELS }}'.split(','); | |
// Read the version map | |
const fs = require('fs'); | |
const versionMap = fs.readFileSync('version_map.json', 'utf8'); | |
let workflowFile; | |
if (testnetKernelsList.includes(kernelAddress)) { | |
workflowFile = 'develop.yml'; | |
} else if (testnetStagingKernelsList.includes(kernelAddress)) { | |
workflowFile = 'staging.yml'; | |
} else { | |
core.setFailed('Error: Kernel not found in known configurations'); | |
return; | |
} | |
try { | |
await github.rest.actions.createWorkflowDispatch({ | |
owner: 'andromedaprotocol', | |
repo: 'andromeda-armour', | |
workflow_id: workflowFile, | |
ref: 'main', | |
inputs: { | |
version_map: versionMap, | |
grep: '@smoke_test' | |
} | |
}); | |
} catch (error) { | |
core.setFailed(`Failed to trigger Armor workflow: ${error.message}`); | |
} |