Skip to content

Commit afad666

Browse files
authored
Create main.yml
1 parent 3b33d44 commit afad666

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

.github/workflows/main.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Go Project Deployment
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
Build:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
go-version: [1.23]
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v2
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v3
20+
with:
21+
go-version: ${{ matrix.go-version }}
22+
23+
- name: Cache Go modules
24+
uses: actions/cache@v2
25+
with:
26+
path: ~/.cache/go-build
27+
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.mod') }}
28+
restore-keys: |
29+
${{ runner.os }}-go-${{ matrix.go-version }}-
30+
31+
- name: Install Dependencies
32+
run: go mod tidy
33+
34+
deploy:
35+
needs: [Build]
36+
runs-on: ubuntu-latest
37+
38+
steps:
39+
- name: Login and deploy Go app
40+
uses: appleboy/ssh-action@v0.1.10
41+
with:
42+
host: ${{ secrets.HOST }}
43+
username: ${{ secrets.USERNAME }}
44+
password: ${{ secrets.PASSWORD }}
45+
port: ${{ secrets.PORT }}
46+
script: |
47+
cd /home/ubuntu/projects/doc-qa/doc-qa-api
48+
sudo git reset --hard
49+
sudo git checkout main
50+
sudo git pull https://github.com/zeus-nishant/doc-qa-api.git
51+
52+
# Copy .env file to the server
53+
echo "${{ secrets.ENV }}" > /home/ubuntu/projects/doc-qa/doc-qa-api/.env
54+
55+
docker stop doc-qa-api && docker system prune && docker compose up -d

0 commit comments

Comments
 (0)