name: Render review deploy 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: # Community Edition create-ce-review-app: if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'create-ce-review-app' || github.event.label.name == 'review-app') }} runs-on: ubuntu-latest steps: - name: Creating deployment for CE id: create-ce-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 ' { "autoDeploy": "yes", "branch": "${{ env.BRANCH_NAME }}", "name": "ToolJet CE PR #${{ env.PR_NUMBER }}", "notifyOnFail": "default", "ownerId": "tea-caeo4bj19n072h3dddc0", "repo": "https://github.com/ToolJet/ToolJet", "slug": "tooljet-ce-pr-${{ env.PR_NUMBER }}", "suspended": "not_suspended", "suspenders": [], "type": "web_service", "envVars": [ { "key": "PG_HOST", "value": "${{ secrets.RENDER_PG_HOST }}" }, { "key": "PG_PORT", "value": "5432" }, { "key": "PG_USER", "value": "${{ secrets.RENDER_PG_USER }}" }, { "key": "PG_PASS", "value": "${{ secrets.RENDER_PG_PASS }}" }, { "key": "PG_DB", "value": "${{ env.PR_NUMBER }}-ce" }, { "key": "TOOLJET_DB", "value": "${{ env.PR_NUMBER }}-ce-tjdb" }, { "key": "TOOLJET_DB_HOST", "value": "${{ secrets.RENDER_PG_HOST }}" }, { "key": "TOOLJET_DB_USER", "value": "${{ secrets.RENDER_PG_USER }}" }, { "key": "TOOLJET_DB_PASS", "value": "${{ secrets.RENDER_PG_PASS }}" }, { "key": "TOOLJET_DB_PORT", "value": "5432" }, { "key": "PGRST_DB_PRE_CONFIG", "value": "postgrest.pre_config" }, { "key": "PGRST_DB_URI", "value": "postgres://${{ secrets.RENDER_PG_USER }}:${{ secrets.RENDER_PG_PASS }}@${{ secrets.RENDER_PG_HOST }}/${{ env.PR_NUMBER }}-ce-tjdb" }, { "key": "PGRST_HOST", "value": "127.0.0.1:3000" }, { "key": "PGRST_JWT_SECRET", "value": "r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj" }, { "key": "PGRST_LOG_LEVEL", "value": "info" }, { "key": "PORT", "value": "80" }, { "key": "TOOLJET_HOST", "value": "https://tooljet-ce-pr-${{ env.PR_NUMBER }}.onrender.com" }, { "key": "DISABLE_TOOLJET_TELEMETRY", "value": "true" }, { "key": "SMTP_ADDRESS", "value": "smtp.mailtrap.io" }, { "key": "SMTP_DOMAIN", "value": "smtp.mailtrap.io" }, { "key": "SMTP_PORT", "value": "2525" }, { "key": "SMTP_USERNAME", "value": "${{ secrets.RENDER_SMTP_USERNAME }}" }, { "key": "SMTP_PASSWORD", "value": "${{ secrets.RENDER_SMTP_PASSWORD }}" }, { "key": "TEMPORAL_SERVER_ADDRESS", "value": "https://auto-setup-1-25-1.onrender.com" }, { "key": "TEMPORAL_TASK_QUEUE_NAME_FOR_WORKFLOWS", "value": "tooljet-ce-pr-${{ env.PR_NUMBER }}" }, { "key": "TOOLJET_WORKFLOWS_TEMPORAL_NAMESPACE", "value": "default" }, { "key": "TOOLJET_MARKETPLACE_URL", "value": "${{ secrets.MARKETPLACE_BUCKET }}" } ], "serviceDetails": { "disk": null, "env": "docker", "envSpecificDetails": { "dockerCommand": "", "dockerContext": "./", "dockerfilePath": "./docker/ce-preview.Dockerfile" }, "healthCheckPath": "/api/health", "numInstances": 1, "openPorts": [{ "port": 80, "protocol": "TCP" }], "plan": "starter", "pullRequestPreviewsEnabled": "no", "region": "oregon", "url": "https://tooljet-ce-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: 'Community Edition:- \n Deployment: https://tooljet-ce-pr-${{ env.PR_NUMBER }}.onrender.com \n Dashboard: https://dashboard.render.com/web/${{ 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-ce-review-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-ce-review-app'] }) destroy-ce-review-app: if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-ce-review-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%20CE%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-ce-review-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-ce-review-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-ce-review-app' }) } catch (e) { console.log(e) } - name: Install PostgreSQL client run: | sudo apt update sudo apt install postgresql-client -y - name: Wait after installing PostgreSQL run: sleep 25 - name: Drop PostgreSQL PR databases env: PGHOST: ${{ secrets.RENDER_DS_PG_HOST }} PGPORT: 5432 PGUSER: ${{ secrets.RENDER_DS_PG_USER }} PGDATABASE: ${{ env.PR_NUMBER }}-ce PGTJBDATABASE: ${{ env.PR_NUMBER }}-ce-tjdb run: | if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGDATABASE; then echo "Database $PGDATABASE exists, deleting..." PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGDATABASE\" ;" else echo "Database $PGDATABASE does not exist." fi if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGTJBDATABASE; then echo "Database $PGTJBDATABASE exists, deleting..." PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGTJBDATABASE\" ;" else echo "Database $PGTJBDATABASE does not exist." fi suspend-ce-review-app: if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-ce-review-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-ce-review-app' }) } catch (e) { console.log(e) } resume-ce-review-app: if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-ce-review-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-ce-review-app'] }) try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, name: 'suspend-ce-review-app' }) } catch (e) { console.log(e) } # Enterprise Edition create-ee-review-app: if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'create-ee-review-app' || github.event.label.name == 'review-app') }} runs-on: ubuntu-latest steps: - name: Creating deployment for Enterprise Edition id: create-ee-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 ' { "autoDeploy": "yes", "branch": "${{ env.BRANCH_NAME }}", "name": "ToolJet EE PR #${{ env.PR_NUMBER }}", "notifyOnFail": "default", "ownerId": "tea-caeo4bj19n072h3dddc0", "repo": "https://github.com/ToolJet/ToolJet", "slug": "tooljet-ee-pr-${{ env.PR_NUMBER }}", "suspended": "not_suspended", "suspenders": [], "type": "web_service", "envVars": [ { "key": "PG_HOST", "value": "${{ secrets.RENDER_PG_HOST }}" }, { "key": "PG_PORT", "value": "5432" }, { "key": "PG_USER", "value": "${{ secrets.RENDER_PG_USER }}" }, { "key": "PG_PASS", "value": "${{ secrets.RENDER_PG_PASS }}" }, { "key": "PG_DB", "value": "${{ env.PR_NUMBER }}-ee" }, { "key": "TOOLJET_DB", "value": "${{ env.PR_NUMBER }}-ee-tjdb" }, { "key": "TOOLJET_DB_HOST", "value": "${{ secrets.RENDER_PG_HOST }}" }, { "key": "TOOLJET_DB_USER", "value": "${{ secrets.RENDER_PG_USER }}" }, { "key": "TOOLJET_DB_PASS", "value": "${{ secrets.RENDER_PG_PASS }}" }, { "key": "TOOLJET_DB_PORT", "value": "5432" }, { "key": "PGRST_DB_PRE_CONFIG", "value": "postgrest.pre_config" }, { "key": "PGRST_DB_URI", "value": "postgres://${{ secrets.RENDER_PG_USER }}:${{ secrets.RENDER_PG_PASS }}@${{ secrets.RENDER_PG_HOST }}/${{ env.PR_NUMBER }}-ee-tjdb" }, { "key": "PGRST_HOST", "value": "127.0.0.1:3000" }, { "key": "PGRST_JWT_SECRET", "value": "r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj" }, { "key": "PGRST_LOG_LEVEL", "value": "info" }, { "key": "PORT", "value": "80" }, { "key": "TOOLJET_HOST", "value": "https://tooljet-ee-pr-${{ env.PR_NUMBER }}.onrender.com" }, { "key": "DISABLE_TOOLJET_TELEMETRY", "value": "true" }, { "key": "SMTP_ADDRESS", "value": "smtp.mailtrap.io" }, { "key": "SMTP_DOMAIN", "value": "smtp.mailtrap.io" }, { "key": "SMTP_PORT", "value": "2525" }, { "key": "SMTP_USERNAME", "value": "${{ secrets.RENDER_SMTP_USERNAME }}" }, { "key": "SMTP_PASSWORD", "value": "${{ secrets.RENDER_SMTP_PASSWORD }}" }, { "key": "REDIS_HOST", "value": "${{ secrets.RENDER_REDIS_HOST }}" }, { "key": "REDIS_PORT", "value": "${{ secrets.RENDER_REDIS_PORT }}" }, { "key": "TEMPORAL_SERVER_ADDRESS", "value": "https://auto-setup-1-25-1.onrender.com" }, { "key": "TEMPORAL_TASK_QUEUE_NAME_FOR_WORKFLOWS", "value": "tooljet-ee-pr-${{ env.PR_NUMBER }}" }, { "key": "TOOLJET_WORKFLOWS_TEMPORAL_NAMESPACE", "value": "default" }, { "key": "TOOLJET_MARKETPLACE_URL", "value": "${{ secrets.MARKETPLACE_BUCKET }}" }, { "key": "BRANCH_NAME", "value": "${{ env.BRANCH_NAME }}" }, { "key": "CUSTOM_GITHUB_TOKEN", "value": "${{ secrets.CUSTOM_GITHUB_TOKEN }}" } ], "serviceDetails": { "disk": null, "env": "docker", "envSpecificDetails": { "dockerCommand": "", "dockerContext": "./", "dockerfilePath": "./docker/ee/ee-preview.Dockerfile" }, "healthCheckPath": "/api/health", "numInstances": 1, "openPorts": [{ "port": 80, "protocol": "TCP" }], "plan": "starter", "pullRequestPreviewsEnabled": "no", "region": "oregon", "url": "https://tooljet-ee-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: 'Enterpise Edition: \n Deployment: https://tooljet-ee-pr-${{ env.PR_NUMBER }}.onrender.com \n Dashboard: https://dashboard.render.com/web/${{ 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-ee-review-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-ee-review-app'] }) destroy-ee-review-app: if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-ee-review-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%20EE%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-ee-review-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-ee-review-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-ee-review-app' }) } catch (e) { console.log(e) } - name: Install PostgreSQL client run: | sudo apt update sudo apt install postgresql-client -y - name: Wait after installing PostgreSQL run: sleep 25 - name: Drop PostgreSQL PR databases env: PGHOST: ${{ secrets.RENDER_DS_PG_HOST }} PGPORT: 5432 PGUSER: ${{ secrets.RENDER_DS_PG_USER }} PGDATABASE: ${{ env.PR_NUMBER }}-ee PGTJBDATABASE: ${{ env.PR_NUMBER }}-ee-tjdb run: | if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGDATABASE; then echo "Database $PGDATABASE exists, deleting..." PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGDATABASE\" ;" else echo "Database $PGDATABASE does not exist." fi if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGTJBDATABASE; then echo "Database $PGTJBDATABASE exists, deleting..." PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGTJBDATABASE\" ;" else echo "Database $PGTJBDATABASE does not exist." fi suspend-ee-review-app: if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-ee-review-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-ee-review-app' }) } catch (e) { console.log(e) } resume-ee-review-app: if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-ee-review-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-ee-review-app'] }) try { await github.rest.issues.removeLabel({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, name: 'suspend-ee-review-app' }) } catch (e) { console.log(e) } # Cloud Edition # create-cloud-review-app: # if: ${{ github.event.action == 'labeled' && (github.event.label.name == 'create-cloud-review-app' || github.event.label.name == 'review-app') }} # runs-on: ubuntu-latest # steps: # - name: Creating deployment for Cloud Edition # id: create-cloud-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 ' # { # "autoDeploy": "yes", # "branch": "${{ env.BRANCH_NAME }}", # "name": "ToolJet Cloud PR #${{ env.PR_NUMBER }}", # "notifyOnFail": "default", # "ownerId": "tea-caeo4bj19n072h3dddc0", # "repo": "https://github.com/ToolJet/ToolJet", # "slug": "tooljet-cloud-pr-${{ env.PR_NUMBER }}", # "suspended": "not_suspended", # "suspenders": [], # "type": "web_service", # "envVars": [ # { # "key": "PG_HOST", # "value": "${{ secrets.RENDER_PG_HOST }}" # }, # { # "key": "PG_PORT", # "value": "5432" # }, # { # "key": "PG_USER", # "value": "${{ secrets.RENDER_PG_USER }}" # }, # { # "key": "PG_PASS", # "value": "${{ secrets.RENDER_PG_PASS }}" # }, # { # "key": "PG_DB", # "value": "${{ env.PR_NUMBER }}-cloud" # }, # { # "key": "TOOLJET_DB", # "value": "${{ env.PR_NUMBER }}-cloud-tjdb" # }, # { # "key": "TOOLJET_DB_HOST", # "value": "${{ secrets.RENDER_PG_HOST }}" # }, # { # "key": "TOOLJET_DB_USER", # "value": "${{ secrets.RENDER_PG_USER }}" # }, # { # "key": "TOOLJET_DB_PASS", # "value": "${{ secrets.RENDER_PG_PASS }}" # }, # { # "key": "TOOLJET_DB_PORT", # "value": "5432" # }, # { # "key": "PGRST_DB_PRE_CONFIG", # "value": "postgrest.pre_config" # }, # { # "key": "PGRST_DB_URI", # "value": "postgres://${{ secrets.RENDER_PG_USER }}:${{ secrets.RENDER_PG_PASS }}@${{ secrets.RENDER_PG_HOST }}/${{ env.PR_NUMBER }}-cloud-tjdb" # }, # { # "key": "PGRST_HOST", # "value": "127.0.0.1:3000" # }, # { # "key": "PGRST_JWT_SECRET", # "value": "r9iMKoe5CRMgvJBBtp4HrqN7QiPpUToj" # }, # { # "key": "PGRST_LOG_LEVEL", # "value": "info" # }, # { # "key": "PORT", # "value": "80" # }, # { # "key": "TOOLJET_HOST", # "value": "https://tooljet-cloud-pr-${{ env.PR_NUMBER }}.onrender.com" # }, # { # "key": "DISABLE_TOOLJET_TELEMETRY", # "value": "true" # }, # { # "key": "SMTP_ADDRESS", # "value": "smtp.mailtrap.io" # }, # { # "key": "SMTP_DOMAIN", # "value": "smtp.mailtrap.io" # }, # { # "key": "SMTP_PORT", # "value": "2525" # }, # { # "key": "SMTP_USERNAME", # "value": "${{ secrets.RENDER_SMTP_USERNAME }}" # }, # { # "key": "SMTP_PASSWORD", # "value": "${{ secrets.RENDER_SMTP_PASSWORD }}" # }, # { # "key": "REDIS_HOST", # "value": "${{ secrets.RENDER_REDIS_HOST }}" # }, # { # "key": "REDIS_PORT", # "value": "${{ secrets.RENDER_REDIS_PORT }}" # }, # { # "key": "TEMPORAL_SERVER_ADDRESS", # "value": "https://auto-setup-1-25-1.onrender.com" # }, # { # "key": "TEMPORAL_TASK_QUEUE_NAME_FOR_WORKFLOWS", # "value": "tooljet-cloud-pr-${{ env.PR_NUMBER }}" # }, # { # "key": "TOOLJET_WORKFLOWS_TEMPORAL_NAMESPACE", # "value": "default" # }, # { # "key": "TOOLJET_MARKETPLACE_URL", # "value": "${{ secrets.MARKETPLACE_BUCKET }}" # }, # { # "key": "CUSTOM_GITHUB_TOKEN", # "value": "${{ secrets.CUSTOM_GITHUB_TOKEN }}" # } # ], # "serviceDetails": { # "disk": null, # "env": "docker", # "envSpecificDetails": { # "dockerCommand": "", # "dockerContext": "./", # "dockerfilePath": "./docker/cloud/cloud-preview.Dockerfile" # }, # "healthCheckPath": "/api/health", # "numInstances": 1, # "openPorts": [{ # "port": 80, # "protocol": "TCP" # }], # "plan": "starter", # "pullRequestPreviewsEnabled": "no", # "region": "oregon", # "url": "https://tooljet-cloud-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: 'Cloud Edition: \n Deployment: https://tooljet-cloud-pr-${{ env.PR_NUMBER }}.onrender.com \n Dashboard: https://dashboard.render.com/web/${{ 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-cloud-review-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-cloud-review-app'] # }) # destroy-cloud-review-app: # if: ${{ (github.event.action == 'labeled' && github.event.label.name == 'destroy-cloud-review-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-cloud-review-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-cloud-review-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-cloud-review-app' # }) # } catch (e) { # console.log(e) # } # - name: Install PostgreSQL client # run: | # sudo apt update # sudo apt install postgresql-client -y # - name: Wait after installing PostgreSQL # run: sleep 25 # - name: Drop PostgreSQL PR databases # env: # PGHOST: ${{ secrets.RENDER_DS_PG_HOST }} # PGPORT: 5432 # PGUSER: ${{ secrets.RENDER_DS_PG_USER }} # PGDATABASE: ${{ env.PR_NUMBER }}-cloud # PGTJBDATABASE: ${{ env.PR_NUMBER }}-cloud-tjdb # run: | # if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGDATABASE; then # echo "Database $PGDATABASE exists, deleting..." # PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGDATABASE\" ;" # else # echo "Database $PGDATABASE does not exist." # fi # if PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -lqt | cut -d \| -f 1 | grep -qw $PGTJBDATABASE; then # echo "Database $PGTJBDATABASE exists, deleting..." # PGPASSWORD=${{ secrets.RENDER_DS_PG_PASS }} psql -h $PGHOST -p $PGPORT -U $PGUSER -d postgres -c "drop database \"$PGTJBDATABASE\" ;" # else # echo "Database $PGTJBDATABASE does not exist." # fi # suspend-cloud-review-app: # if: ${{ github.event.action == 'labeled' && github.event.label.name == 'suspend-cloud-review-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-cloud-review-app' # }) # } catch (e) { # console.log(e) # } # resume-cloud-review-app: # if: ${{ github.event.action == 'unlabeled' && github.event.label.name == 'suspend-cloud-review-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-cloud-review-app'] # }) # try { # await github.rest.issues.removeLabel({ # issue_number: context.issue.number, # owner: context.repo.owner, # repo: context.repo.repo, # name: 'suspend-cloud-review-app' # }) # } catch (e) { # console.log(e) # }