Manual Deployment to Dev #12
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: Manual Deployment to Dev | |
on: | |
workflow_dispatch: | |
inputs: | |
network: | |
description: "Network for Subgraph deployment - (Gnosis Chain or Ethereum)" | |
required: true | |
options: | |
- Ethereum | |
- Gnosis Chain | |
- ALL | |
type: choice | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
deploy: | |
name: Deployment | |
runs-on: ubuntu-latest | |
outputs: | |
random_id: ${{ steps.random_id.outputs.random_id }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v2 | |
with: | |
path: '**/node_modules' | |
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} | |
- name: Check for excluded branches | |
if: startsWith(github.ref, 'refs/heads/main') | |
run: | | |
echo "This branch is excluded from workflow dispatch." | |
exit 1 | |
- name: Generate Random ID | |
id: random_id | |
run: | | |
echo "random_id=$(openssl rand -hex 8)" >> $GITHUB_OUTPUT | |
- name: Setup Node.js | |
uses: actions/setup-node@v2 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Install graph-cli & dependencies | |
run: | | |
yarn run clean | |
yarn global add @graphprotocol/graph-cli | |
yarn install | |
- name: Build Subgraph for ETH mainnet | |
if: ${{ inputs.network == 'Ethereum' }} | |
run: yarn codegen && yarn build | |
- name: Build Subgraph for Gnosis Chain | |
if: ${{ inputs.network == 'Gnosis Chain' }} | |
run: yarn codegen && yarn build:gc | |
- name: Build Subgraph for both Netwroks | |
if: ${{ inputs.network == 'ALL' }} | |
run: yarn doall | |
- name: Authenticate to Subgraph Studio | |
run: graph auth --studio ${{ secrets.DEPLOY_KEY }} | |
# Script to deploy to development environment | |
- name: Deploy Subgraph for ETH mainnet | |
if: ${{ inputs.network == 'Ethereum' }} | |
run: yarn deploy -l "${{ github.event.inputs.branch }}-${{ steps.random_id.outputs.random_id }}" | |
- name: Deploy Subgraph for Gnosis Chain | |
if: ${{ inputs.network == 'Gnosis Chain' }} | |
run: yarn deploy:gc -l "${{ github.event.inputs.branch }}-${{ steps.random_id.outputs.random_id }}" | |
- name: Deploy Subgraph for both Netwroks | |
if: ${{ inputs.network == 'ALL' }} | |
run: yarn deploy -l "${{ github.event.inputs.branch }}-${{ steps.random_id.outputs.random_id }}" && yarn deploy:gc -l "${{ github.event.inputs.branch }}-${{ steps.random_id.outputs.random_id }}" | |
notify: | |
uses: ./.github/workflows/slack_release_notification.yml | |
if: ${{ always() }} | |
needs: deploy | |
secrets: | |
RELEASES_SLACK_WEBHOOK_URL: ${{ secrets.RELEASES_SLACK_WEBHOOK_URL }} | |
with: | |
environment: Development | |
service: GC Voting Snapshot SubGraph | |
success: ${{ contains(join(needs.*.result, ','), 'success') }} | |
message: "deploy service `GC Voting Snapshot SubGraph` version `${{ github.event.inputs.branch }}-${{ needs.deploy.outputs.random_id }}`. Triggered by `${{ github.actor }}`." | |