[FEATURE-51] CORS 에러 재수정 #48
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI/CD Automation using github actions and Docker | |
on: | |
push: | |
branches: '*' | |
pull_request: | |
branches: [ 'main' ] | |
permissions: | |
contents: read | |
jobs: | |
## CI | |
build: | |
name: CI | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout java code | |
uses: actions/checkout@v3 | |
- name: Set up Jdk 11 ver | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'temurin' | |
# Gradle 캐싱 빌드 시간 향상 | |
- 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- | |
- name: Grant execute Permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew build -x test | |
# Dockerhub Login | |
- name: Login to Dockerhub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{secrets.DOCKER_USERNAME}} | |
password: ${{secrets.DOCKER_PASSWORD}} | |
# Docker buildx set up | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Docker build & push | |
- name: Docker build & push to DockerHub | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
## CD | |
deploy: | |
name: CD | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
# Deploy to prod | |
- name: Connect to WAS & Execute Application | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST_IP }} # EC2 퍼블릭 IPv4 DNS | |
username: ${{ secrets.USERNAME }} # ubuntu | |
port: 22 | |
key: ${{ secrets.PRIVATE_KEY }} # pem | |
script: | | |
docker -v | |
docker ps | |
docker stop $(docker ps -aq) | |
docker rm $(docker ps -aq) | |
docker image rm $(docker images -q) | |
docker pull ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
docker run -d -p 8080:8080 --name ${{ secrets.CONTAINER_NAME }} --env-file .env ${{ secrets.DOCKER_USERNAME }}/better-iter:latest | |
docker ps | |