Skip to content

feat: use common mocks and token calls generators #174

feat: use common mocks and token calls generators

feat: use common mocks and token calls generators #174

# This workflow is triggered when a pull request is closed on the 'develop' or 'main' branches
# and there is a change to the 'packages/subgraph/package.json' file.
name: Subgraph Deploy
on:
workflow_dispatch:
pull_request:
types:
- closed
branches:
- develop
- main
paths:
- 'packages/subgraph/package.json'
- '.github/workflows/subgraph-deploy.yaml'
jobs:
# The prepare job is responsible for preparing the environment and generating outputs for other jobs.
prepare:
if: github.actor != 'arabot-1'
runs-on: ubuntu-latest
outputs:
environment: ${{ steps.prepare.outputs.environment }}
matrix: ${{ steps.prepare.outputs.matrix }}
steps:
- uses: actions/checkout@v2
- name: Prepare
id: prepare
run: node .github/helpers/subgraph/buildMatrix.js '${{ github.ref }}'
# The changelog job updates the changelog file in the 'packages/subgraph' directory.
# It runs only when a pull request is merged, the actor is not 'arabot-1',
# and the pull request has a label that contains 'subgraph:deploy'.
changelog:
runs-on: ubuntu-latest
if: >
github.event.pull_request.merged &&
github.actor != 'arabot-1' &&
contains(toJson(github.event.pull_request.labels.*.name), 'subgraph:deploy')
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
token: ${{secrets.ARABOT_PAT}}
- name: Update Changelog
working-directory: packages/subgraph
run: |
VERSION=$(cat package.json | jq -r .version)
sed -i "s/^\#\# \[UPCOMING\]/## [UPCOMING]\n\n\## $VERSION/" "./CHANGELOG.md"
- uses: planetscale/[email protected]
with:
commit_message: 'Update changelog in subgraph'
repo: ${{ github.repository }}
branch: ${{ github.base_ref || github.head_ref || github.ref_name }}
file_pattern: 'packages/subgraph/CHANGELOG.md'
env:
GITHUB_TOKEN: ${{secrets.ARABOT_PAT}}
# The build-deploy job builds and deploys the subgraph.
# It depends on the prepare and changelog jobs to complete successfully,
# and the pull request has a label that contains 'subgraph:deploy'.
build-deploy:
runs-on: ubuntu-latest
needs: [prepare, changelog]
if: >
always() && (
(github.event_name == 'workflow_dispatch') || (
needs.changelog.result == 'success' &&
contains(toJson(github.event.pull_request.labels.*.name), 'subgraph:deploy')))
environment: ${{ needs.prepare.outputs.environment }}
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.base_ref || github.ref }}
- name: Install node
uses: actions/setup-node@v3
with:
cache: 'yarn'
node-version: 16
- name: Install dependencies
run: yarn install --pure-lockfile
- name: Build Contracts
run: cd ./packages/contracts/ && yarn run build
- name: Deploy Subgraph
run: |
cd ./packages/subgraph/
export SUBGRAPH_VERSION="v$(cat package.json | jq -r .version)"
yarn run deploy
env:
SUBGRAPH_NAME: osx
NETWORK_NAME: ${{ matrix.network }}
GRAPH_KEY: ${{ secrets.GRAPH_KEY }}