diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml new file mode 100644 index 0000000..2ea097a --- /dev/null +++ b/.github/workflows/github-actions.yml @@ -0,0 +1,145 @@ +# github repository actions 페이지에 나타날 이름 +name: CI/CD using github actions & docker + +# event trigger +# main이나 feature/#1 브랜치에 push가 되었을 때 실행 +on: + push: + branches: ["main", "feature/#1"] + +permissions: + contents: read + +jobs: + CI-CD: + runs-on: ubuntu-latest + steps: + # JDK setting - github actions에서 사용할 JDK 설정 (프로젝트나 AWS의 java 버전과 달라도 무방) + - uses: actions/checkout@v3 + - name: Set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: "11" + distribution: "temurin" + + - name: checkout + uses: actions/checkout@master + + - name: create env file + run: | + touch .env + echo "${{ secrets.ENV_VARS }}" >> .env + + # - name: executing remote ssh commands using password + # uses: appleboy/ssh-action@master + # with: + # host: ${{ secrets.HOST }} + # username: ubuntu + # key: ${{ secrets.PRIVATE_KEY }} + # script: | + # sh ../../deploy.sh + + # # gradle caching - 빌드 시간 향상 + # - name: Gradle Caching + # uses: actions/cache@v3 + # with: + # path: | + # ~/.gradle/caches + # ~/.gradle/wrapper + # key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + # restore-keys: | + # ${{ runner.os }}-gradle- + + # # # 환경별 yml 파일 생성(1) - application.yml + # # - name: make application.yml + # # if: | + # # contains(github.ref, 'main') || + # # contains(github.ref, 'develop') + # # run: | + # # mkdir ./Backend/src/main/resources # resources 폴더 생성 + # # cd ./Backend/src/main/resources # resources 폴더로 이동 + # # touch ./application.yml # application.yml 생성 + # # echo "${{ secrets.YML }}" > ./application.yml # github actions에서 설정한 값을 application.yml 파일에 쓰기 + # # shell: bash + + # # 환경별 yml 파일 생성(1) - api + # - name: make application-api.yml + # contains(github.ref, 'main') || + # contains(github.ref, 'feature/#1') + # run: | + # cd ../../Backend/src/main/resources/security + # touch ./application-api.yml + # echo "${{ secrets.YML_API }}" > ./application-api.yml + # shell: bash + + # # 환경별 yml 파일 생성(2) - database + # - name: make application-database.yml + + # contains(github.ref, 'main') || + # contains(github.ref, 'feature/#1') + # run: | + # cd ../../Backend/src/main/resources/security + # touch ./application-database.yml + # echo "${{ secrets.YML_DATABASE }}" > ./application-database.yml + # shell: bash + + # # 환경별 yml 파일 생성(3) - security + # - name: make application-security.yml + # contains(github.ref, 'main') || + # contains(github.ref, 'feature/#1') + # run: | + # cd ../../Backend/src/main/resources/security + # touch ./application-security.yml + # echo "${{ secrets.YML_SECURITY }}" > ./application-security.yml + # shell: bash + + # # gradle build + # - name: Build with Gradle + # run: ./gradlew build -x test + + # # docker build & push to production + # - name: Docker build & push to prod + # if: contains(github.ref, 'main') + # run: | + # docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + # docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/docker-test-prod . + # docker push ${{ secrets.DOCKER_USERNAME }}/docker-test-prod + + # # docker build & push to develop + # - name: Docker build & push to dev + # if: contains(github.ref, 'feature/#1') + # run: | + # docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + # docker build -f Dockerfile-dev -t ${{ secrets.DOCKER_USERNAME }}/docker-test-dev . + # docker push ${{ secrets.DOCKER_USERNAME }}/docker-test-dev + + # ## deploy to production + # - name: Deploy to prod + # uses: appleboy/ssh-action@master + # id: deploy-prod + # if: contains(github.ref, 'main') + # with: + # host: ${{ secrets.HOST }} # EC2 퍼블릭 IPv4 DNS + # username: ubuntu + # key: ${{ secrets.PRIVATE_KEY }} + # # envs: GITHUB_SHA + # script: | + # sudo docker ps + # sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test-prod + # docker-compose up -d + # sudo docker image prune -f + + # # deploy to develop + # - name: Deploy to dev + # uses: appleboy/ssh-action@master + # id: deploy-dev + # if: contains(github.ref, 'feature/#1') + # with: + # host: ${{ secrets.HOST }} # EC2 퍼블릭 IPv4 DNS + # username: ubuntu + # key: ${{ secrets.PRIVATE_KEY }} + # script: | + # sudo docker ps + # sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test-dev + # docker-compose up -d + # sudo docker image prune -f diff --git a/Android b/Android index 126a84d..4c3213f 160000 --- a/Android +++ b/Android @@ -1 +1 @@ -Subproject commit 126a84d16ebaae203d0a40aa0cf81a2b2036c44f +Subproject commit 4c3213fdb5690e4ca031591c10982547253db5f9 diff --git a/Backend b/Backend index 1ad380d..60f7f0b 160000 --- a/Backend +++ b/Backend @@ -1 +1 @@ -Subproject commit 1ad380d2d50fc54a9be4ad8fb0a83eaba8e0a83d +Subproject commit 60f7f0b1c0e1ecdef43994af600b4d5affb48e30 diff --git a/deploy.sh b/deploy.sh new file mode 100644 index 0000000..7adbf64 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Installing docker engine if not exists +if ! type docker > /dev/null +then + echo "docker does not exist" + echo "Start installing docker" + sudo apt-get update + sudo apt install -y apt-transport-https ca-certificates curl software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable" + sudo apt update + apt-cache policy docker-ce + sudo apt install -y docker-ce +fi + +# Installing docker-compose if not exists +if ! type docker-compose > /dev/null +then + echo "docker-compose does not exist" + echo "Start installing docker-compose" + sudo curl -L "https://github.com/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose +fi + +echo "start submoudle update" +cd /home/ubuntu/srv/ubuntu +mkdir alertmanager +sudo git submodule init +sudo git submodule update --recursive --remote --merge +# sudo mv /home/ubuntu/srv/ubuntu/.env /home/ubuntu/srv/ubuntu/backend/ +# echo "start docker-compose up: ubuntu" +# sudo docker-compose -f /home/ubuntu/srv/ubuntu/docker-compose.yml up --build -d \ No newline at end of file