-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57ef5dc
commit 40217d3
Showing
2 changed files
with
90 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
.github/workflows/ci-cd-pipeline.yml → .github/workflows/ci.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: CI/CD Pipeline | ||
name: CI Pipeline | ||
|
||
on: | ||
push: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
name: Deploy to AWS | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Checkout the repository | ||
- name: Checkout Code | ||
uses: actions/checkout@v2 | ||
|
||
# Set up SSH Key for EC2 Access | ||
- name: Set Up SSH | ||
env: | ||
SSH_KEY: ${{ secrets.EC2_SSH_KEY }} | ||
run: | | ||
mkdir -p ~/.ssh | ||
echo "$SSH_KEY" > ~/.ssh/id_rsa | ||
chmod 600 ~/.ssh/id_rsa | ||
# Copy backend files to EC2 | ||
- name: Deploy Application to EC2 | ||
env: | ||
EC2_USER: ${{ secrets.EC2_USER }} | ||
EC2_HOST: ${{ secrets.EC2_HOST }} | ||
run: | | ||
echo "Copying backend directory to EC2..." | ||
scp -o StrictHostKeyChecking=no -r backend/docker-compose.yml $EC2_USER@$EC2_HOST:~/job-application-tracker/ | ||
# Create .env file on EC2 | ||
- name: Configure Environment Variables | ||
env: | ||
APP_URL: ${{ secrets.APP_URL }} | ||
PORT: ${{ secrets.PORT }} | ||
ALLOWED_ORIGINS: ${{ secrets.ALLOWED_ORIGINS }} | ||
DB_USER: ${{ secrets.DB_USER }} | ||
DB_PASS: ${{ secrets.DB_PASS }} | ||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} | ||
KEY_STORE_PASS: ${{ secrets.KEY_STORE_PASS }} | ||
KEY_STORE_ALIAS: ${{ secrets.KEY_STORE_ALIAS }} | ||
MAIL_HOST: ${{ secrets.MAIL_HOST }} | ||
MAIL_PORT: ${{ secrets.MAIL_PORT }} | ||
MAIL_USER: ${{ secrets.MAIL_USER }} | ||
MAIL_PASS: ${{ secrets.MAIL_PASS }} | ||
TURNSTILE_SECRET: ${{ secrets.TURNSTILE_SECRET }} | ||
run: | | ||
echo "Creating .env file on EC2..." | ||
ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << 'EOF' | ||
mkdir -p ~/job-application-tracker | ||
cat <<EOT > ~/job-application-tracker/.env | ||
APP_URL=${APP_URL} | ||
PORT=${PORT} | ||
ALLOWED_ORIGINS=${ALLOWED_ORIGINS} | ||
DB_USER=${DB_USER} | ||
DB_PASS=${DB_PASS} | ||
GEMINI_API_KEY=${GEMINI_API_KEY} | ||
KEY_STORE_PASS=${KEY_STORE_PASS} | ||
KEY_STORE_ALIAS=${KEY_STORE_ALIAS} | ||
MAIL_HOST=${MAIL_HOST} | ||
MAIL_PORT=${MAIL_PORT} | ||
MAIL_USER=${MAIL_USER} | ||
MAIL_PASS=${MAIL_PASS} | ||
TURNSTILE_SECRET=${TURNSTILE_SECRET} | ||
EOT | ||
EOF | ||
# Start Application on EC2 | ||
- name: Start Application | ||
env: | ||
EC2_USER: ${{ secrets.EC2_USER }} | ||
EC2_HOST: ${{ secrets.EC2_HOST }} | ||
run: | | ||
echo "Deploying application on EC2..." | ||
ssh -o StrictHostKeyChecking=no $EC2_USER@$EC2_HOST << 'EOF' | ||
cd ~/job-application-tracker | ||
docker-compose down | ||
docker-compose up --build -d | ||
EOF | ||