The currently used `v1` is deprecated, and not recommended anymore. The
`v4` changes a few things. Some details are in the following pages:
1. https://github.com/docker/build-push-action/blob/v2/UPGRADE.md
2.
4fad532b9f/README.md (customizing)
Essentially, in the current code, `build-args` isn't working. This
should fix that.
251 lines
11 KiB
YAML
251 lines
11 KiB
YAML
name: Ad-hoc DP | Build Push Deploy from branch ( To be used by ops.appsmith.com API layer only)
|
|
|
|
on:
|
|
# This workflow is only triggered by the `/build-deploy-preview` command dispatch
|
|
workflow_dispatch:
|
|
inputs:
|
|
branch:
|
|
description: "Github Branch to be deployed"
|
|
required: true
|
|
default: "release"
|
|
skip-tests:
|
|
description: "Flag to skip Cypress tests"
|
|
required: true
|
|
default: "true"
|
|
uid:
|
|
description: "Unique ID to store the run data in the db"
|
|
required: false
|
|
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)"
|
|
required: true
|
|
jobs:
|
|
# write-job-details-to-db:
|
|
# runs-on: ubuntu-latest
|
|
# 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: {
|
|
# run_id: ${{ github.run_id }},
|
|
# status: "BUILD IN PROGRESS"
|
|
# }
|
|
# }
|
|
# )'
|
|
# #TODO Add mongo URI as secret
|
|
|
|
server-build:
|
|
name: server-build
|
|
uses: ./.github/workflows/server-build.yml
|
|
secrets: inherit
|
|
with:
|
|
branch: ${{ github.event.inputs.branch }}
|
|
skip-tests: ${{ github.event.inputs.skip-tests }}
|
|
|
|
client-build:
|
|
name: client-build
|
|
uses: ./.github/workflows/client-build.yml
|
|
secrets: inherit
|
|
with:
|
|
branch: ${{ github.event.inputs.branch }}
|
|
skip-tests: ${{ github.event.inputs.skip-tests }}
|
|
|
|
rts-build:
|
|
name: rts-build
|
|
uses: ./.github/workflows/rts-build.yml
|
|
secrets: inherit
|
|
with:
|
|
branch: ${{ github.event.inputs.branch }}
|
|
|
|
push-image:
|
|
needs: [client-build, rts-build, server-build]
|
|
runs-on: ubuntu-latest
|
|
if: success()
|
|
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
|
|
- name: Checkout PR
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: "refs/pull/${{ github.event.client_payload.pull_request.number }}/merge"
|
|
|
|
# Timestamp will be used to create cache key
|
|
- id: timestamp
|
|
run: echo "timestamp=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT
|
|
|
|
# get Git-hash will be used to create cache key
|
|
- id: git_hash
|
|
run: echo "git_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
|
|
|
- name: Download the client build artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: client-build
|
|
path: app/client
|
|
|
|
- name: Unpack the client build artifact
|
|
if: steps.run_result.outputs.run_result != 'success'
|
|
run: |
|
|
mkdir -p app/client/build
|
|
tar -xvf app/client/build.tar -C app/client/build
|
|
|
|
- name: Download the server build artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: server-build
|
|
path: app/server/dist
|
|
|
|
- name: Download the rts build artifact
|
|
uses: actions/download-artifact@v3
|
|
with:
|
|
name: rts-dist
|
|
path: app/client/packages/rts/dist
|
|
|
|
- name: Untar the rts folder
|
|
run: |
|
|
tar -xvf app/client/packages/rts/dist/rts-dist.tar -C app/client/packages/rts/
|
|
echo "Cleaning up the tar files"
|
|
rm app/client/packages/rts/dist/rts-dist.tar
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
with:
|
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
|
|
- name: Push to Docker Hub
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
pull: true
|
|
push: true
|
|
cache-from: ${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-${{ vars.EDITION }}:release
|
|
tags: |
|
|
${{ vars.DOCKER_HUB_ORGANIZATION }}/appsmith-dp:${{ github.event.inputs.sub-domain-name }}
|
|
build-args: |
|
|
APPSMITH_CLOUD_SERVICES_BASE_URL=https://release-cs.appsmith.com
|
|
|
|
outputs:
|
|
imageHash: ${{ github.event.inputs.sub-domain-name }}
|
|
|
|
build-deploy-preview:
|
|
needs: [push-image]
|
|
runs-on: ubuntu-latest
|
|
defaults:
|
|
run:
|
|
working-directory: "."
|
|
|
|
if: success()
|
|
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
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: "refs/pull/${{ github.event.client_payload.pull_request.number }}/merge"
|
|
fetch-depth: 0
|
|
|
|
- name: Install relevant packages
|
|
run: |
|
|
which aws
|
|
sudo apt update -q && sudo apt install -y curl unzip less jq
|
|
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.23.6/bin/linux/amd64/kubectl && \
|
|
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && \
|
|
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 && \
|
|
chmod 700 get_helm.sh; ./get_helm.sh
|
|
|
|
- name: Deploy Helm chart
|
|
env:
|
|
AWS_ROLE_ARN: ${{ secrets.APPSMITH_EKS_AWS_ROLE_ARN }}
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.APPSMITH_CI_AWS_SECRET_ACCESS_KEY_ID }}
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.APPSMITH_CI_AWS_SECRET_ACCESS_KEY }}
|
|
IMAGE_HASH: ${{ needs.push-image.outputs.imageHash }}
|
|
AWS_RELEASE_CERT: ${{ secrets.APPSMITH_AWS_RELEASE_CERT_RELEASE }}
|
|
DOCKER_HUB_ORGANIZATION: ${{ vars.DOCKER_HUB_ORGANIZATION }}
|
|
DOCKER_HUB_USERNAME: ${{ secrets.DOCKER_HUB_USERNAME }}
|
|
DOCKER_HUB_ACCESS_TOKEN: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
|
SUB_DOMAIN_NAME: ${{ github.event.inputs.sub-domain-name }}
|
|
# RECREATE: ${{ github.event.client_payload.slash_command.args.named.recreate }}
|
|
DB_USERNAME: ${{ secrets.DB_USERNAME }}
|
|
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
|
DB_URL: ${{ secrets.DB_URL }}
|
|
run: |
|
|
echo "environment variables set to deploy the image" $IMAGE_HASH
|
|
/bin/bash ./scripts/build_dp_form_branch.sh
|
|
|
|
update-db-on-completion:
|
|
needs: [build-deploy-preview]
|
|
runs-on: ubuntu-latest
|
|
if: success()
|
|
steps:
|
|
- run: echo "Workflow completed successfully!"
|
|
|
|
# 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
|
|
# }
|
|
# }
|
|
# )'
|
|
|