Chore: 불필요한 CookieUtils 클래스 제거 (#181) #54
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: CD | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Generate environment file | |
run: | | |
mkdir -p env | |
echo "${{secrets.DOCKER_COMPOSE_ENV}}" >> env/docker-compose.env | |
echo "${{secrets.AWS_ENV}}" >> env/aws.env | |
echo "${{secrets.TEST_DB_ENV}}" >> env/test-db.env | |
echo "${{secrets.DEV_DB_ENV}}" >> env/dev-db.env | |
echo "${{secrets.TEST_REDIS_ENV}}" >> env/test-redis.env | |
echo "${{secrets.DEV_REDIS_ENV}}" >> env/dev-redis.env | |
- name: Run docker DB, Redis container | |
run: | | |
docker-compose -f ./docker/docker-compose.yml up -d db | |
docker-compose -f ./docker/docker-compose.yml up -d redis | |
- name: Get execution permission to gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
- name: Build and push docker image | |
run: | | |
docker login -u ${{secrets.DOCKERHUB_USERNAME}} -p ${{secrets.DOCKERHUB_PASSWORD}} | |
docker build -t ${{secrets.DOCKERHUB_USERNAME}}/seat-view-reviews:latest . | |
docker push ${{secrets.DOCKERHUB_USERNAME}}/seat-view-reviews:latest | |
- name: Get github actions public IP | |
id: ip | |
uses: haythem/[email protected] | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY}} | |
aws-secret-access-key: ${{secrets.AWS_SECRET_KEY}} | |
aws-region: ap-northeast-2 | |
- name: Add github actions IP to security group | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{secrets.AWS_SECURITY_GROUP_ID}} --protocol tcp --port 22 --cidr ${{steps.ip.outputs.ipv4}}/32 | |
- name: Send necessary files to EC2 | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{secrets.EC2_HOST}} | |
username: ${{secrets.EC2_USERNAME}} | |
key: ${{secrets.EC2_KEY}} | |
port: ${{secrets.EC2_PORT}} | |
source: "env/*,docker/*" | |
strip_components: 0 | |
target: "~" | |
- name: Access AWS EC2 and run the app | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{secrets.EC2_HOST}} | |
username: ${{secrets.EC2_USERNAME}} | |
key: ${{secrets.EC2_KEY}} | |
port: ${{secrets.EC2_PORT}} | |
script: | | |
docker-compose -f ./docker/docker-compose.yml stop | |
docker-compose -f ./docker/docker-compose.yml pull | |
docker-compose -f ./docker/docker-compose.yml up -d | |
- name: Remove github actions IP from security group | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{secrets.AWS_SECURITY_GROUP_ID}} --protocol tcp --port 22 --cidr ${{steps.ip.outputs.ipv4}}/32 |