-
Notifications
You must be signed in to change notification settings - Fork 0
51 lines (41 loc) · 1.31 KB
/
Copy pathcd.yml
File metadata and controls
51 lines (41 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
name: CD
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission
run: chmod +x ./gradlew
- name: Build
run: ./gradlew clean build -x test
- name: Login Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build & Push Image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:latest -t ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }} .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:latest
docker push ${{ secrets.DOCKERHUB_USERNAME }}/mua-backend:${{ github.sha }}
- name: Deploy to WAS
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.WAS_HOST }}
username: ec2-user
key: ${{ secrets.SSH_KEY }}
port: 22
script: |
cd /home/ec2-user
docker compose pull
docker compose down
docker compose up -d