Skip to content

Commit

Permalink
Modified the prod deployment as tag base
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhilashKD committed Oct 14, 2024
1 parent 7018c05 commit 58a7dde
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 60 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/dev-pratham-deployment.yaml

This file was deleted.

56 changes: 46 additions & 10 deletions .github/workflows/prod-pratham-deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,25 +1,61 @@
name: Deployment on the Pratham-PROD Frontend Server
name: PROD FRONTEND DEPLOYMENT WITH TAG
on:
push:
branches:
- main
tags:
- 'v*'

jobs:
PROD-PRAHAM-DEPLOYMENT:
PROD-FRONTEND-TAG-BASE-DEPLOYMENT:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Set TAG environment variable
id: get_tag
run: |
# Extract the tag from the ref and set it as an environment variable
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Debug TAG value
run: |
# Print the TAG value to ensure the correct tag is being used
echo "TAG value - ${{ env.TAG }}"
- name: Deploy Stack
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_NAME_PROD }}
username: ${{ secrets.USERNAME_PROD }}
key: ${{ secrets.EC2_SSH_KEY_PROD }}
key: ${{ secrets.SSH_KEY_PROD }}
port: ${{ secrets.PORT_PROD }}
script: |
cd ${{ secrets.TARGET_DIR_PROD }}
if [ -f .env ]; then
rm .env
# Assign the TAG value from the environment variable
TAG="${{ env.TAG }}"
# Define the target directory and environment file
TARGET_DIR="${{ secrets.TARGET_DIR_PROD }}"
ENVIRONMENT="$TARGET_DIR/.env"
# Remove the existing .env file if it exists
if [ -f "$ENVIRONMENT" ]; then
rm "$ENVIRONMENT"
fi
echo "${{ secrets.PROD_ENV }}" > .env
# Create the target directory if it doesn't exist and write environment variables to .env
mkdir -p "$TARGET_DIR"
cat << EOF > "$ENVIRONMENT"
${{ secrets.PROD_ENV }}
EOF
# Navigate to the target directory
cd ${{ secrets.TARGET_DIR_PROD }}
# List the contents of the directory for verification
ls -ltra
./deploy.sh
# Run the deployment script with the correct TAG
./deploy.sh $TAG
25 changes: 0 additions & 25 deletions .github/workflows/tekdi-server-deployment.yaml

This file was deleted.

0 comments on commit 58a7dde

Please sign in to comment.