Skip to content

Commit 00b4fed

Browse files
committed
Workflow changes
1 parent 755ec44 commit 00b4fed

File tree

3 files changed

+9
-40
lines changed

3 files changed

+9
-40
lines changed

.github/workflows/deploy-surge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: deploy-surge
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66

77
jobs:
88
build:

.github/workflows/docker-image.yml

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,17 @@
1-
name: CI/CD Direct Deploy to Server
1+
name: Auto Deploy
22

33
on:
44
push:
55
branches:
6-
- main
6+
- master
77

88
jobs:
99
deploy:
10-
runs-on: ubuntu-latest
10+
runs-on: [self-hosted]
11+
1112
steps:
12-
- name: Checkout repo
13+
- name: Checkout repository
1314
uses: actions/checkout@v4
1415

15-
- name: Deploy to server via SSH
16-
uses: appleboy/ssh-action@v1.1.0
17-
with:
18-
host: ${{ secrets.SERVER_HOST }}
19-
username: ${{ secrets.SERVER_USER }}
20-
key: ${{ secrets.SERVER_SSH_KEY }}
21-
script: |
22-
set -e
23-
APP_NAME=iiitt-new-dev
24-
echo "Updating repository..."
25-
git fetch origin main
26-
git pull origin main
27-
28-
if [ "$(docker ps -q -f name=$APP_NAME)" ]; then
29-
echo "Backing up current container..."
30-
docker commit $APP_NAME ${IMAGE_NAME}:backup
31-
docker stop $APP_NAME || true
32-
docker rm $APP_NAME || true
33-
fi
34-
35-
echo "Building new image..."
36-
docker build -t ${IMAGE_NAME}:latest -t ${IMAGE_NAME}:${COMMIT_SHA} .
37-
38-
echo "Running new container..."
39-
docker run -d --name $APP_NAME -p ${SERVER_PORT}:${DOCKER_PORT} ${IMAGE_NAME}:latest
40-
41-
echo "Cleaning up old images..."
42-
docker image prune -a --filter "until=48h" --filter "dangling=true" -f
43-
for img in $(docker images -q); do
44-
if ! docker ps -a --format '{{.Image}}' | grep -q $img; then
45-
echo "Removing unused image $img"
46-
docker rmi -f $img || true
47-
fi
48-
done
16+
- name: Run deployment script
17+
run: ./deploy.sh

.github/workflows/pr-deploy-surge.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: pr-deploy-surge
33
on:
44
pull_request:
55
branches:
6-
- master
6+
- main
77
jobs:
88
console-for-all:
99
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)