Skip to content

Commit

Permalink
Merge pull request #5888 from Countly/pipeline/stable-je-cb
Browse files Browse the repository at this point in the history
Pipeline/stable je cb
  • Loading branch information
ihaardik authored Jan 6, 2025
2 parents 822d8c3 + e17e7d5 commit 433041d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/stable-je-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a basic workflow to help you get started with Actions

name: Deploy Journey Engine

# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ next ]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
deploy:
runs-on: ubuntu-latest

steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3

- name: Deploy server
shell: bash
env:
SSH_PRIVATE_KEY: ${{ secrets.STABLE_JE_SSH_PRIVATE_KEY }}
run: bash ./bin/scripts/deploy-je.sh
22 changes: 22 additions & 0 deletions bin/scripts/deploy-je.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Generate a timestamp for the log file
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
LOG_FILE="deploy_$TIMESTAMP.log"

# Check if the event is a push to the "next" branch in the "Countly/countly-server" repository
if [ -z "$GITHUB_HEAD_REF" ] && [ "$GITHUB_REPOSITORY" == "Countly/countly-server" ]; then
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
echo "$GITHUB_BRANCH"
if [ "$GITHUB_BRANCH" == "next" ]; then
echo "$SSH_PRIVATE_KEY" > je-deploy-key
mkdir -p ~/.ssh
mv je-deploy-key ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa

# Log the deployment command with a timestamped log file
ssh -oStrictHostKeyChecking=no "[email protected]" \
"sudo su -c 'bash /opt/deploy.sh > /var/log/github-action/$LOG_FILE 2>&1 &'"
fi
fi

0 comments on commit 433041d

Please sign in to comment.