Deploy Subgraph #141
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 Subgraph | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: "Deployment environment (prod/dev/testing)" | |
required: true | |
subgraph: | |
description: "Subgraph name (beanstalk/bean/basin/beanft)" | |
required: true | |
branch: | |
description: "Branch name" | |
required: true | |
jobs: | |
validation: | |
runs-on: ubuntu-latest | |
outputs: | |
environment: ${{ steps.check_env.outputs.environment }} | |
steps: | |
- name: Validate environment input | |
id: check_env | |
run: | | |
# Check if the environment is prod/dev/testing/prev | |
if [[ "${{ github.event.inputs.environment }}" != "prod" && "${{ github.event.inputs.environment }}" != "dev" && "${{ github.event.inputs.environment }}" != "testing" && "${{ github.event.inputs.environment }}" != "prev" ]]; then | |
echo "Error: Environment must be one of 'prod', 'dev', 'testing'." | |
exit 1 | |
fi | |
# Check if the subgraph is a valid selection | |
if [[ ! "${{ github.event.inputs.subgraph }}" =~ ^(beanstalk|bean|basin|beanft) ]]; then | |
echo "Error: Subgraph must be one of 'beanstalk', 'bean', 'basin', 'beanft'." | |
exit 1 | |
fi | |
deploy: | |
needs: validation | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install SSH key | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.GRAPH_SERVER_SSH_KEY }}" > ~/.ssh/id_ed25519 | |
chmod 600 ~/.ssh/id_ed25519 | |
ssh-keyscan -H ${{ secrets.GRAPH_SERVER_HOST }} >> ~/.ssh/known_hosts | |
- name: Execute Remote Deployment Script | |
run: ssh -i ~/.ssh/id_ed25519 github@${{ secrets.GRAPH_SERVER_HOST }} "bash /home/github/deploy.sh ${{ github.event.inputs.branch }} ${{ github.event.inputs.subgraph }} ${{ github.event.inputs.environment }}" |