✨ feat(api, search): add custom path of the swagger-ui using… #51
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: Street Drop CI/CD | |
on: | |
push: | |
branches: [ "main" ] | |
paths: | |
- "backend/streetdrop-api/**" | |
- "backend/streetdrop-domain/**" | |
- "backend/streetdrop-common/**" | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
- name: Set up JDK 19 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '19' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
working-directory: ./backend | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
working-directory: ./backend | |
run: ./gradlew clean build --exclude-task test | |
- name: Cache Gradle package | |
uses: actions/cache@v1 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Login To DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Build and push Docker image | |
uses: docker/[email protected] | |
with: | |
context: . | |
file: ./backend/streetdrop-api/Dockerfile | |
push: true | |
build-args: | | |
DB_URL=${{ secrets.DB_URL }} | |
DB_USERNAME=${{ secrets.DB_USERNAME }} | |
DB_PASSWORD=${{ secrets.DB_PASSWORD }} | |
SWAGGER_SERVER_URL=${{ secrets.SWAGGER_SERVER_URL }} | |
AWS_ACCESS_KEY=${{ secrets.AWS_ACCESS_KEY }} | |
AWS_SECRET_KEY=${{ secrets.AWS_SECRET_KEY }} | |
AWS_BUCKET_NAME=${{ secrets.AWS_BUCKET_NAME }} | |
AWS_REGION=${{ secrets.AWS_REGION }} | |
SLACK_TOEKN=${{ secrets.SLACK_TOKEN }} | |
tags: | | |
${{ secrets.DOCKER_REPO }}/street-drop-api-server:latest | |
- name: Get Github 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_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
- name: Add GitHub IP to AWS | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
- name: Deploy | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USERNAME }} | |
password: ${{ secrets.EC2_PASSWORD }} | |
port: ${{ secrets.EC2_SSH_PORT }} | |
timeout: 60s | |
script: | | |
cd street-drop-server/ | |
sudo docker rm - f $(docker ps -qa) | |
sudo docker pull ${{ secrets.DOCKER_REPO }}/street-drop-api-server:latest | |
sudo docker stop $(sudo docker ps -aq) | |
sudo docker run -d ${{ secrets.DOCKER_REPO }}/street-drop-api-server:latest \ | |
--name street-drop-api \ | |
-p 8080:8080 street-drop-api \ | |
- name: Remove IP FROM security group | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_SG_ID }} --protocol tcp --port 22 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |