Skip to content

Commit f856813

Browse files
committed
feat: add studio URL as output
Add studio_url output alongside existing studio_query_url to provide users with the dashboard link. Refactors deployment logic into a separate script for better maintainability.
1 parent 4ac23aa commit f856813

4 files changed

Lines changed: 55 additions & 8 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
node_modules/
2-
yarn-error.log
2+
yarn-error.log
3+
.vscode
4+
*.code-workspace

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,18 @@ jobs:
2626
run: yarn codegen
2727
- name: Build
2828
run: yarn build
29-
- uses: gtaschuk/graph-deploy@v0.1.0
29+
- id: graph-deploy
30+
uses: gtaschuk/graph-deploy@v0.1.0
3031
with:
3132
graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}}
3233
graph_subgraph_name: "your-subgraph-name"
3334
graph_deploy_studio: "true"
3435
graph_account: "your-github-name-or-organization"
3536
graph_config_file: "subgraph.yml"
37+
graph_version_label: "v0.0.6"
38+
- name: Check deploy success
39+
run: echo "Deploy succeeded? ${{ steps.graph-deploy.outputs.success }}"
40+
- name: Surface Studio query URL
41+
if: ${{ steps.graph-deploy.outputs.success == 'success' && steps.graph-deploy.outputs.studio_query_url != '' }}
42+
run: echo "Query endpoint: ${{ steps.graph-deploy.outputs.studio_query_url }}"
3643
```

action.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ inputs:
3030
outputs:
3131
success:
3232
description: 'The Success/Failure of the action'
33+
value: ${{ steps.deploy.outcome }}
34+
studio_query_url:
35+
description: 'Graph Studio query URL for the deployed version'
36+
value: ${{ steps.deploy.outputs.studio_query_url }}
3337
runs:
3438
using: 'composite'
3539
steps:
@@ -39,10 +43,13 @@ runs:
3943
echo "$(yarn global bin)" >> $GITHUB_PATH
4044
shell: bash
4145
- id: deploy
42-
run: |
43-
if [ "${{inputs.graph_deploy_studio}}" = "true" ]; then
44-
graph deploy --studio --deploy-key ${{inputs.graph_deploy_key}} ${{inputs.graph_subgraph_name}} ${{inputs.graph_config_file}} --version-label ${{inputs.graph_version_label}}
45-
else
46-
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/
47-
fi
4846
shell: bash
47+
env:
48+
GRAPH_ACCESS_TOKEN: ${{ inputs.graph_access_token }}
49+
GRAPH_ACCOUNT: ${{ inputs.graph_account }}
50+
GRAPH_CONFIG_FILE: ${{ inputs.graph_config_file }}
51+
GRAPH_DEPLOY_KEY: ${{ inputs.graph_deploy_key }}
52+
GRAPH_DEPLOY_STUDIO: ${{ inputs.graph_deploy_studio }}
53+
GRAPH_SUBGRAPH_NAME: ${{ inputs.graph_subgraph_name }}
54+
GRAPH_VERSION_LABEL: ${{ inputs.graph_version_label }}
55+
run: ./scripts/graph-deploy.sh

scripts/graph-deploy.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
LOG_FILE="$(mktemp)"
5+
trap 'rm -f "$LOG_FILE"' EXIT
6+
7+
if [ "${GRAPH_DEPLOY_STUDIO}" = "true" ]; then
8+
graph deploy \
9+
--studio \
10+
--deploy-key "${GRAPH_DEPLOY_KEY}" \
11+
"${GRAPH_SUBGRAPH_NAME}" \
12+
"${GRAPH_CONFIG_FILE}" \
13+
--version-label "${GRAPH_VERSION_LABEL}" | tee "$LOG_FILE"
14+
else
15+
graph deploy \
16+
--access-token "${GRAPH_ACCESS_TOKEN}" \
17+
"${GRAPH_ACCOUNT}/${GRAPH_SUBGRAPH_NAME}" \
18+
"${GRAPH_CONFIG_FILE}" \
19+
--ipfs https://api.thegraph.com/ipfs/ \
20+
--node https://api.thegraph.com/deploy/ | tee "$LOG_FILE"
21+
fi
22+
23+
if [ "${GRAPH_DEPLOY_STUDIO}" = "true" ]; then
24+
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)"
25+
26+
if [ -n "$studio_query_url" ]; then
27+
echo "studio_query_url=$studio_query_url" >> "$GITHUB_OUTPUT"
28+
else
29+
echo "Unable to parse Studio query URL from deploy output. Ensure you are using the latest graph-cli." >&2
30+
fi
31+
fi

0 commit comments

Comments
 (0)