Skip to content

chore: main to develop #161

chore: main to develop

chore: main to develop #161

# 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:
pull_request:
types:
- closed
branches:
- develop
- main
paths:
- 'packages/subgraph/package.json'
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')
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Update Changelog
working-directory: packages/subgraph
run: |
VERSION=$(cat package.json | jq -r .version)
sed -i "s/^\#\# \[UPCOMING\]/## [UPCOMING]\n\n\## $VERSION\nOn $(date +'%Y-%m-%d %H:%M:%S')/" "./CHANGELOG.md"
- name: Commit changes
id: commit
run: |
git fetch
git pull
git config --global user.name "Arabot-1"
git config --global user.email "[email protected]"
git add packages/subgraph/CHANGELOG.md
git commit -am "Update changelog in subgraph"
git push
# 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: >
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 }}