Files
crypto_clash/.github/workflows/deploy_backend.yml

57 lines
1.6 KiB
YAML

name: Deploy Contract
on:
workflow_dispatch:
push:
branches:
- main
paths:
- 'crypto_clash_contract/**'
- '.github/workflows/deploy_backend.yml'
permissions:
contents: write
actions: write
jobs:
build-and-deploy-contract:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v6
with:
# update the Node version to meet your needs
node-version: 24
cache: npm
cache-dependency-path: crypto_clash_contract/package-lock.json
- name: Install dependencies and compile/deploy contract
run: npm ci && npm run compile && npm run deploy
working-directory: crypto_clash_contract
env:
API_URL: ${{ vars.API_URL }}
WALLET_PRIVATE_KEY: ${{ secrets.WALLET_PRIVATE_KEY }}
- name: Push config.json to artifacts
uses: actions/upload-artifact@v5
with:
name: contract-config
path: config.json
- name: Commit deployed contract address
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add config.json
git commit -m "Update deployed contract address" || echo "No changes to commit"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger frontend deployment
run: |
gh workflow run deploy_frontend.yml -r main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}