ci: Deploy preview from branch (#25846)
Updated ad-hoc dp workflow to update the db with progress. - This workflow should only be called via internal ops api. - This workflow uses the internal ops api to patch data with the updates on the workflow statuses. --------- Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com>
This commit is contained in:
parent
d58c7ff8d3
commit
be9c935732
134
.github/workflows/ad-hoc-deploy-preview.yml
vendored
134
.github/workflows/ad-hoc-deploy-preview.yml
vendored
|
|
@ -12,37 +12,26 @@ on:
|
||||||
description: "Flag to skip Cypress tests"
|
description: "Flag to skip Cypress tests"
|
||||||
required: true
|
required: true
|
||||||
default: "true"
|
default: "true"
|
||||||
uid:
|
id:
|
||||||
description: "Unique ID to store the run data in the db"
|
description: "Document ID for the workflow entry in the MongoDB ( This gets initialized by the ops api )"
|
||||||
required: false
|
required: true
|
||||||
sub-domain-name:
|
sub-domain-name:
|
||||||
description: "Sub-domain for dp.appsmith.com to by used by this deploy preview (This will also be the image name and the k8s namespace identifier)"
|
description: "Sub-domain for dp.appsmith.com to by used by this deploy preview (This will also be the image name and the k8s namespace identifier)"
|
||||||
required: true
|
required: true
|
||||||
jobs:
|
jobs:
|
||||||
# write-job-details-to-db:
|
update-job-details-to-db:
|
||||||
# runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
# steps:
|
steps:
|
||||||
# - name: Install mongosh
|
- name: Update workflow details
|
||||||
# run: |
|
run: |
|
||||||
# sudo apt-get update
|
curl --request PATCH 'https://ops.appsmith.com/appsmith_deploy_workflow/${{github.event.inputs.uid}}' \
|
||||||
# sudo apt-get install -y wget gnupg
|
--header 'Content-Type: application/json' \
|
||||||
# wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
--oauth2-bearer '${{secrets.INTENRAL_OPS_API_TOKEN}}' \
|
||||||
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
--data ' {
|
||||||
# sudo apt-get update
|
"status": "IN_PROGRESS",
|
||||||
# sudo apt-get install -y mongodb-mongosh
|
"githubWorkflowId": "${{github.workflow.id}}",
|
||||||
# - name: Update job data to mongoDB
|
"githubWorkflowHtmlUrl": "${{github.workflow.githubWorkflowHtmlUrl}}",
|
||||||
# run: |
|
}'
|
||||||
# # mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.insert( { run_id: ${{ github.run_id }}, uid: ${{ github.event.inputs.uid }}, status: "Started" } )'
|
|
||||||
# mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.update(
|
|
||||||
# { _id: ${{ github.event.inputs.uid }} },
|
|
||||||
# {
|
|
||||||
# $set: {
|
|
||||||
# run_id: ${{ github.run_id }},
|
|
||||||
# status: "BUILD IN PROGRESS"
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )'
|
|
||||||
# #TODO Add mongo URI as secret
|
|
||||||
|
|
||||||
server-build:
|
server-build:
|
||||||
name: server-build
|
name: server-build
|
||||||
|
|
@ -72,31 +61,11 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: success()
|
if: success()
|
||||||
steps:
|
steps:
|
||||||
# - name: Install mongosh
|
|
||||||
# run: |
|
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get install -y wget gnupg
|
|
||||||
# wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
|
||||||
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get install -y mongodb-mongosh
|
|
||||||
# - name: Update job data to mongoDB
|
|
||||||
# run: |
|
|
||||||
# # mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.insert( { run_id: ${{ github.run_id }}, uid: ${{ github.event.inputs.uid }}, status: "Started" } )'
|
|
||||||
# mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.update(
|
|
||||||
# { _id: ${{ github.event.inputs.uid }} },
|
|
||||||
# {
|
|
||||||
# $set: {
|
|
||||||
# status: "BUILD SUCCESSFUL"
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )'
|
|
||||||
|
|
||||||
# Check out merge commit
|
# Check out merge commit
|
||||||
- name: Checkout PR
|
- name: Checkout Branch
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "refs/pull/${{ github.event.client_payload.pull_request.number }}/merge"
|
ref: ${{ github.event.inputs.branch }}
|
||||||
|
|
||||||
# Timestamp will be used to create cache key
|
# Timestamp will be used to create cache key
|
||||||
- id: timestamp
|
- id: timestamp
|
||||||
|
|
@ -166,30 +135,10 @@ jobs:
|
||||||
|
|
||||||
if: success()
|
if: success()
|
||||||
steps:
|
steps:
|
||||||
- name: Install mongosh
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y wget gnupg
|
|
||||||
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
|
||||||
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y mongodb-mongosh
|
|
||||||
- name: Update job data to mongoDB
|
|
||||||
run: |
|
|
||||||
# mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.insert( { run_id: ${{ github.run_id }}, uid: ${{ github.event.inputs.uid }}, status: "Started" } )'
|
|
||||||
# mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.update(
|
|
||||||
# { _id: ${{ github.event.inputs.uid }} },
|
|
||||||
# {
|
|
||||||
# $set: {
|
|
||||||
# status: "DEPLOYMENT IN PROGRESS"
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )'
|
|
||||||
- name: Checkout PR
|
- name: Checkout PR
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
ref: "refs/pull/${{ github.event.client_payload.pull_request.number }}/merge"
|
ref: ${{ github.event.inputs.branch }}
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Install relevant packages
|
- name: Install relevant packages
|
||||||
run: |
|
run: |
|
||||||
|
|
@ -216,35 +165,30 @@ jobs:
|
||||||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||||
DB_URL: ${{ secrets.DB_URL }}
|
DB_URL: ${{ secrets.DB_URL }}
|
||||||
run: |
|
run: |
|
||||||
echo "environment variables set to deploy the image" $IMAGE_HASH
|
echo "environment variables set to deploy the image $IMAGE_HASH"
|
||||||
/bin/bash ./scripts/build_dp_form_branch.sh
|
/bin/bash ./scripts/build_dp_from_branch.sh
|
||||||
|
|
||||||
update-db-on-completion:
|
update-db-on-completion:
|
||||||
needs: [build-deploy-preview]
|
needs: [build-deploy-preview]
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: success()
|
|
||||||
steps:
|
steps:
|
||||||
- run: echo "Workflow completed successfully!"
|
- name: Update workflow completed successfully
|
||||||
|
if: success()
|
||||||
|
run: |
|
||||||
|
curl --request PATCH 'https://ops.appsmith.com/appsmith_deploy_workflow/${{github.event.inputs.id}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--oauth2-bearer '${{secrets.INTENRAL_OPS_API_TOKEN}}' \
|
||||||
|
--data ' {
|
||||||
|
"status": "COMPLETED"
|
||||||
|
}'
|
||||||
|
- name: Update workflow failure
|
||||||
|
if: failure()
|
||||||
|
run: |
|
||||||
|
curl --request PATCH 'https://ops.appsmith.com/appsmith_deploy_workflow/${{github.event.inputs.id}}' \
|
||||||
|
--header 'Content-Type: application/json' \
|
||||||
|
--oauth2-bearer '${{secrets.INTENRAL_OPS_API_TOKEN}}' \
|
||||||
|
--data ' {
|
||||||
|
"status": "FAILED"
|
||||||
|
}'
|
||||||
|
|
||||||
# This step creates a comment on the PR with a link to this workflow run.
|
|
||||||
# - name: Install mongosh
|
|
||||||
# run: |
|
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get install -y wget gnupg
|
|
||||||
# wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
|
|
||||||
# echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
|
|
||||||
# sudo apt-get update
|
|
||||||
# sudo apt-get install -y mongodb-mongosh
|
|
||||||
# - name: Update job data to mongoDB
|
|
||||||
# run: |
|
|
||||||
# # mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.insert( { run_id: ${{ github.run_id }}, uid: ${{ github.event.inputs.uid }}, status: "Started" } )'
|
|
||||||
# mongosh '' --eval 'db.appsmiht-ce-github-dp-runs.update(
|
|
||||||
# { _id: ${{ github.event.inputs.uid }} },
|
|
||||||
# {
|
|
||||||
# $set: {
|
|
||||||
# status: "DEPLOYMENT COMPLETE"
|
|
||||||
# url: https://${{ github.event.inputs.sub-domain-name }}.dp.appsmith.com
|
|
||||||
# }
|
|
||||||
# }
|
|
||||||
# )'
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,9 @@
|
||||||
|
|
||||||
mkdir ~/.aws; touch ~/.aws/config
|
mkdir ~/.aws; touch ~/.aws/config
|
||||||
|
|
||||||
|
echo "[default]
|
||||||
|
aws_access_key_id = $AWS_ACCESS_KEY_ID
|
||||||
|
aws_secret_access_key = $AWS_SECRET_ACCESS_KEY" > ~/.aws/credentials
|
||||||
|
|
||||||
echo "[default]
|
echo "[default]
|
||||||
[profile eksci]
|
[profile eksci]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user