Skip to content

Commit 0a4674a

Browse files
committed
pipeline to upgrade stable-je-cb instance
1 parent 822d8c3 commit 0a4674a

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Deploy Journey Engine
4+
5+
# Controls when the workflow will run
6+
on:
7+
# Triggers the workflow on push or pull request events but only for the master branch
8+
push:
9+
branches: [ pipeline/stable-je-cb ]
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
15+
jobs:
16+
# This workflow contains a single job called "build"
17+
deploy:
18+
runs-on: ubuntu-latest
19+
20+
steps:
21+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
22+
- uses: actions/checkout@v3
23+
24+
- name: Deploy server
25+
shell: bash
26+
env:
27+
SSH_PRIVATE_KEY: ${{ secrets.STABLE_JE_SSH_PRIVATE_KEY }}
28+
run: bash ./bin/scripts/deploy-je.sh

bin/scripts/deploy-je.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Generate a timestamp for the log file
4+
TIMESTAMP=$(date +"%Y%m%d_%H%M%S")
5+
LOG_FILE="deploy_$TIMESTAMP.log"
6+
7+
# Check if the event is a push to the "next" branch in the "Countly/countly-server" repository
8+
if [ -z "$GITHUB_HEAD_REF" ] && [ "$GITHUB_REPOSITORY" == "Countly/countly-server" ]; then
9+
GITHUB_BRANCH=${GITHUB_REF#refs/heads/}
10+
echo "$GITHUB_BRANCH"
11+
if [ "$GITHUB_BRANCH" == "pipeline/stable-je-cb" ]; then
12+
echo "$SSH_PRIVATE_KEY" > je-deploy-key
13+
mkdir -p ~/.ssh
14+
mv je-deploy-key ~/.ssh/id_rsa
15+
chmod 600 ~/.ssh/id_rsa
16+
17+
# Log the deployment command with a timestamped log file
18+
ssh -oStrictHostKeyChecking=no "[email protected]" \
19+
"sudo su -c 'bash /opt/deploy.sh > /var/log/github-action/$LOG_FILE 2>&1 &'"
20+
fi
21+
fi
22+

0 commit comments

Comments
 (0)