forked from devlup-labs/woc
-
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.
Merge branch 'soc' of https://github.com/Abhinav232004/woc into soc
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
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,48 @@ | ||
name: Docker-CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # Set your main branch here | ||
- soc # Set your soc branch here | ||
pull_request: | ||
branches: | ||
- main | ||
- soc | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
|
||
env: | ||
CI: false | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Run Docker Compose | ||
run: | | ||
cp .env.example .env | ||
docker-compose -f docker-compose.yml up -d | ||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
||
- name: Set up gcloud CLI | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
credentials_json: ${{ secrets.GCP_SA_KEY }} | ||
|
||
- name: Check if directory exists on VM | ||
run: | | ||
EXISTS=$(gcloud compute ssh "${{ secrets.GCP_INSTANCE_NAME }}" --zone="${{ secrets.GCP_ZONE }}" --command="if [ -d /SkillWell ]; then echo 'true'; else echo 'false'; fi" 2>/dev/null) | ||
if [ "$EXISTS" = "true" ]; then | ||
echo "Directory already exists on VM. Skipping clone." | ||
else | ||
echo "Directory does not exist on VM. Cloning repository." | ||
gcloud compute ssh "${{ secrets.GCP_INSTANCE_NAME }}" --zone="${{ secrets.GCP_ZONE }}" --command="git clone -b soc ${{ secrets.REPO_URL }}" # Use -b to specify the branch | ||
fi |