mirror of
https://github.com/ToolJet/ToolJet
synced 2026-04-24 06:57:40 +00:00
109 lines
3.5 KiB
YAML
109 lines
3.5 KiB
YAML
name: Test system deploy
|
|
|
|
on:
|
|
pull_request_target:
|
|
types: [labeled, unlabeled, closed]
|
|
|
|
workflow_dispatch:
|
|
|
|
|
|
env:
|
|
PR_NUMBER: ${{ github.event.number }}
|
|
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
|
|
|
|
jobs:
|
|
Build-and-update-image:
|
|
runs-on: ubuntu-22.04
|
|
|
|
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'test-system-deploy' }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.ref }}
|
|
|
|
# Create Docker Buildx builder with platform configuration
|
|
- name: Set up Docker Buildx
|
|
run: |
|
|
mkdir -p ~/.docker/cli-plugins
|
|
curl -SL https://github.com/docker/buildx/releases/download/v0.11.0/buildx-v0.11.0.linux-amd64 -o ~/.docker/cli-plugins/docker-buildx
|
|
chmod a+x ~/.docker/cli-plugins/docker-buildx
|
|
docker buildx create --name mybuilder --platform linux/arm64,linux/amd64,linux/amd64/v2,linux/riscv64,linux/ppc64le,linux/s390x,linux/386,linux/mips64le,linux/mips64,linux/arm/v7,linux/arm/v6
|
|
docker buildx use mybuilder
|
|
|
|
- name: Set DOCKER_CLI_EXPERIMENTAL
|
|
run: echo "DOCKER_CLI_EXPERIMENTAL=enabled" >> $GITHUB_ENV
|
|
|
|
- name: use mybuilder buildx
|
|
run: docker buildx use mybuilder
|
|
|
|
- name: Docker Login
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: Set SAFE_BRANCH_NAME
|
|
run: echo "SAFE_BRANCH_NAME=$(echo ${{ env.BRANCH_NAME }} | tr '/' '-')" >> $GITHUB_ENV
|
|
|
|
- name: Build and Push Docker image
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: .
|
|
file: docker/production.Dockerfile
|
|
push: true
|
|
tags: tooljet/tj-osv:${{ env.SAFE_BRANCH_NAME }}
|
|
platforms: linux/amd64
|
|
env:
|
|
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
|
|
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
|
|
|
|
- name: SSH into EC2 instance
|
|
uses: appleboy/ssh-action@master
|
|
with:
|
|
host: ${{ secrets.EC2_INSTANCE_IP }}
|
|
username: admin
|
|
key: ${{ secrets.EC2_INSTANCE_SSH_KEY }}
|
|
script: |
|
|
ls -lah
|
|
|
|
# Stop the Docker containers
|
|
sudo docker-compose down
|
|
|
|
# Remove the existing tooljet/* images
|
|
sudo docker images -a | grep 'tooljet/' | awk '{print $3}' | xargs sudo docker rmi -f
|
|
|
|
#checking images
|
|
sudo docker images
|
|
|
|
# Update docker-compose.yml with the new image
|
|
sed -i '/^[[:space:]]*tooljet:/,/^$/ s|^\([[:space:]]*image:[[:space:]]*\).*|\1tooljet/tj-osv:${{ env.SAFE_BRANCH_NAME }}|' docker-compose.yaml
|
|
|
|
# Start the Docker containers
|
|
cat docker-compose.yaml
|
|
sudo docker-compose up -d
|
|
|
|
#View containers
|
|
sudo docker ps
|
|
|
|
- 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: 'test-system-deploy'
|
|
})
|
|
} catch (e) {
|
|
console.log(e)
|
|
}
|
|
|
|
await github.rest.issues.addLabels({
|
|
issue_number: context.issue.number,
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
labels: ['test-system-deployed']
|
|
})
|