Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
node_modules/
yarn-error.log
yarn-error.log
.vscode
*.code-workspace
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,18 @@ jobs:
run: yarn codegen
- name: Build
run: yarn build
- uses: gtaschuk/graph-deploy@v0.1.0
- id: graph-deploy
uses: gtaschuk/graph-deploy@v0.1.0
with:
graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
graph_subgraph_name: "your-subgraph-name"
graph_deploy_studio: "true"
graph_account: "your-github-name-or-organization"
graph_config_file: "subgraph.yml"
graph_version_label: "v0.0.6"
- name: Check deploy success
run: echo "Deploy succeeded? ${{ steps.graph-deploy.outputs.success }}"
- name: Surface Studio query URL
if: ${{ steps.graph-deploy.outputs.success == 'success' && steps.graph-deploy.outputs.studio_query_url != '' }}
run: echo "Query endpoint: ${{ steps.graph-deploy.outputs.studio_query_url }}"
```
19 changes: 13 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inputs:
outputs:
success:
description: 'The Success/Failure of the action'
value: ${{ steps.deploy.outcome }}
studio_query_url:
description: 'Graph Studio query URL for the deployed version'
value: ${{ steps.deploy.outputs.studio_query_url }}
runs:
using: 'composite'
steps:
Expand All @@ -39,10 +43,13 @@ runs:
echo "$(yarn global bin)" >> $GITHUB_PATH
shell: bash
- id: deploy
run: |
if [ "${{inputs.graph_deploy_studio}}" = "true" ]; then
graph deploy --studio --deploy-key ${{inputs.graph_deploy_key}} ${{inputs.graph_subgraph_name}} ${{inputs.graph_config_file}} --version-label ${{inputs.graph_version_label}}
else
graph deploy --access-token ${{inputs.graph_access_token}} ${{inputs.graph_account}}/${{inputs.graph_subgraph_name}} ${{inputs.graph_config_file}} --ipfs https://api.thegraph.com/ipfs/ --node https://api.thegraph.com/deploy/
fi
shell: bash
env:
GRAPH_ACCESS_TOKEN: ${{ inputs.graph_access_token }}
GRAPH_ACCOUNT: ${{ inputs.graph_account }}
GRAPH_CONFIG_FILE: ${{ inputs.graph_config_file }}
GRAPH_DEPLOY_KEY: ${{ inputs.graph_deploy_key }}
GRAPH_DEPLOY_STUDIO: ${{ inputs.graph_deploy_studio }}
GRAPH_SUBGRAPH_NAME: ${{ inputs.graph_subgraph_name }}
GRAPH_VERSION_LABEL: ${{ inputs.graph_version_label }}
run: ./scripts/graph-deploy.sh
31 changes: 31 additions & 0 deletions scripts/graph-deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash
set -euo pipefail

LOG_FILE="$(mktemp)"
trap 'rm -f "$LOG_FILE"' EXIT

if [ "${GRAPH_DEPLOY_STUDIO}" = "true" ]; then
graph deploy \
--studio \
--deploy-key "${GRAPH_DEPLOY_KEY}" \
"${GRAPH_SUBGRAPH_NAME}" \
"${GRAPH_CONFIG_FILE}" \
--version-label "${GRAPH_VERSION_LABEL}" | tee "$LOG_FILE"
else
graph deploy \
--access-token "${GRAPH_ACCESS_TOKEN}" \
"${GRAPH_ACCOUNT}/${GRAPH_SUBGRAPH_NAME}" \
"${GRAPH_CONFIG_FILE}" \
--ipfs https://api.thegraph.com/ipfs/ \
--node https://api.thegraph.com/deploy/ | tee "$LOG_FILE"
fi

if [ "${GRAPH_DEPLOY_STUDIO}" = "true" ]; then
studio_query_url="$(grep -Eo 'https://api\.studio\.thegraph\.com/query/[A-Za-z0-9_-]+/[A-Za-z0-9_-]+/[A-Za-z0-9._-]+' "$LOG_FILE" | tail -n 1 || true)"

if [ -n "$studio_query_url" ]; then
echo "studio_query_url=$studio_query_url" >> "$GITHUB_OUTPUT"
else
echo "Unable to parse Studio query URL from deploy output. Ensure you are using the latest graph-cli." >&2
fi
fi