-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (47 loc) · 2 KB
/
maven.yml
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
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
name: Java CI with Maven
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package -DskipTests=true --file pom.xml
- name: Docker Build
run : |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build --no-cache -t backend .
docker tag backend ${{ secrets.DOCKER_USERNAME }}/backend:${GITHUB_SHA::7}
docker push ${{ secrets.DOCKER_USERNAME }}/backend:${GITHUB_SHA::7}
- name: Add public IP to AWS security group
uses: sohelamin/aws-security-group-add-ip-action@master
with:
aws-access-key-id: ${{ secrets.AWS_APPLICATION_DEPLOY_ACCESS_ID }}
aws-secret-access-key: ${{ secrets.AWS_APPLICATION_DEPLOY_ACCESS_KEY }}
aws-region: 'ap-northeast-2'
aws-security-group-id: ${{ secrets.AWS_APPLICATION_DEPLOY_SECURITY_GROUP_ID }}
port: '22'
to-port: '30'
protocol: 'tcp'
description: 'GitHub Action'
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.AWS_APPLICATION_DEPLOY_HOST }}
username: ${{ secrets.AWS_APPLICATION_DEPLOY_USERNAME }}
key: ${{ secrets.AWS_APPLICATION_DEPLOY_PRIVATE_KEY }}
envs: GITHUB_SHA
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/backend:${GITHUB_SHA::7}
sudo docker tag ${{ secrets.DOCKER_USERNAME }}/backend:${GITHUB_SHA::7} backend
sudo docker service update slam-dev --image backend:latest --force