-
Notifications
You must be signed in to change notification settings - Fork 78
48 lines (44 loc) · 1.8 KB
/
deploy.subgraph.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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 }}"