fix: set preview loader only when running query is executed #4684
Workflow file for this run
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: Render PR deploy Docs | |
on: | |
pull_request_target: | |
types: [labeled, unlabeled, closed] | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
BRANCH_NAME: ${{ github.head_ref || github.ref_name }} | |
permissions: | |
pull-requests: write | |
issues: write | |
jobs: | |
create-review-docs-app: | |
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'create-review-docs-app' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create deployment | |
id: create-deployment | |
run: | | |
export RESPONSE=$(curl --request POST \ | |
--url https://api.render.com/v1/services \ | |
--header 'accept: application/json' \ | |
--header 'content-type: application/json' \ | |
--header 'Authorization: Bearer ${{ secrets.RENDER_API_KEY }}' \ | |
--data ' | |
{ | |
"type": "static_site", | |
"autoDeploy": "yes", | |
"branch": "${{ env.BRANCH_NAME }}", | |
"name": "ToolJet PR #${{ env.PR_NUMBER }}", | |
"ownerId": "tea-caeo4bj19n072h3dddc0", | |
"repo": "${{ github.event.pull_request.head.repo.git_url }}", | |
"rootDir": "docs", | |
"envVars": [ | |
{ | |
"key": "NODE_ENV", | |
"value": "production" | |
}, | |
{ | |
"key": "NODE_VERSION", | |
"value": "18.18.2" | |
}, | |
{ | |
"key": "NPM_VERSION", | |
"value": "9.8.1" | |
}, | |
{ | |
"key": "GTM", | |
"value": "dummy" | |
} | |
], | |
"serviceDetails": { | |
"pullRequestPreviewsEnabled": "no", | |
"buildCommand": "bash build-latest-version.sh", | |
"publishPath": "build/", | |
"url": "https://tooljet-pr-${{ env.PR_NUMBER }}.onrender.com" | |
} | |
}') | |
echo "response: $RESPONSE" | |
export SERVICE_ID=$(echo $RESPONSE | jq -r '.service.id') | |
echo "SERVICE_ID=$SERVICE_ID" >> $GITHUB_ENV | |
- name: Comment deployment URL | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Deployment: https://tooljet-pr-${{ env.PR_NUMBER }}.onrender.com \n Dashboard: https://dashboard.render.com/static/${{ env.SERVICE_ID }}' | |
}) | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'create-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} | |
await github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ['active-review-docs-app'] | |
}) | |
destroy-review-docs-app: | |
if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-review-docs-app') || github.event.action == 'closed' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Delete service | |
run: | | |
export SERVICE_ID=$(curl --request GET \ | |
--url 'https://api.render.com/v1/services?name=ToolJet%20PR%20%23${{ env.PR_NUMBER }}&limit=1' \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | \ | |
jq -r '.[0].service.id') | |
curl --request DELETE \ | |
--url https://api.render.com/v1/services/$SERVICE_ID \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'destroy-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'suspend-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'active-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} | |
suspend-review-docs-app: | |
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-review-docs-app' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Suspend service | |
run: | | |
export SERVICE_ID=$(curl --request GET \ | |
--url 'https://api.render.com/v1/services?name=ToolJet%20PR%20%23${{ env.PR_NUMBER }}&limit=1' \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | \ | |
jq -r '.[0].service.id') | |
curl --request POST \ | |
--url https://api.render.com/v1/services/$SERVICE_ID/suspend \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'active-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} | |
resume-review-docs-app: | |
if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-review-docs-app' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Resume service | |
run: | | |
export SERVICE_ID=$(curl --request GET \ | |
--url 'https://api.render.com/v1/services?name=ToolJet%20PR%20%23${{ env.PR_NUMBER }}&limit=1' \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | \ | |
jq -r '.[0].service.id') | |
curl --request POST \ | |
--url https://api.render.com/v1/services/$SERVICE_ID/resume \ | |
--header 'accept: application/json' \ | |
--header 'authorization: Bearer ${{ secrets.RENDER_API_KEY }}' | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
await github.rest.issues.addLabels({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: ['active-review-docs-app'] | |
}) | |
try { | |
await github.rest.issues.removeLabel({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: 'suspend-review-docs-app' | |
}) | |
} catch (e) { | |
console.log(e) | |
} |