refact: delete table change #275
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ main ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'zulu' | |
- name: Grant execute permission for gradlew | |
working-directory: server/ | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
working-directory: server/ | |
run: ./gradlew build | |
- name: Docker build | |
env: | |
MYSQL_PASSWORD: ${{ secrets.MYSQL_PASSWORD }} | |
JWT_SECRET_KEY: ${{ secrets.JWT_SECRET_KEY }} | |
run: | | |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }} | |
docker build -f server/Dockerfile -t green . | |
docker tag green strkawk/green:${GITHUB_SHA::7} | |
docker push strkawk/green:${GITHUB_SHA::7} | |
- 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_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Start Session Manager session | |
run: aws ssm start-session --target i-0df501af4faa42fe6 | |
- name: Deploy to Server | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: ap-northeast-2 | |
run: | | |
aws ssm send-command \ | |
--instance-ids i-0df501af4faa42fe6 \ | |
--document-name "AWS-RunShellScript" \ | |
--parameters "commands=[ | |
'if sudo docker ps -a --format \\'{{.Names}}\\' | grep -q \'^server$\\'; then', | |
' sudo docker stop server', | |
' sudo docker rm server', | |
'fi', | |
'sudo docker pull strkawk/green:${GITHUB_SHA::7}', | |
'sudo docker tag strkawk/green:${GITHUB_SHA::7} green', | |
'sudo docker run -d --name server -p 8080:8080 -e JWT_SECRET_KEY=${{ secrets.JWT_SECRET_KEY }} -e MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }} -e DB_URL=${{ secrets.DB_URL }} -e S3_DOMAIN=${{ secrets.S3_DOMAIN }} green' | |
]" \ | |
--output text |