Skip to content

Commit

Permalink
Chore: actions-runner
Browse files Browse the repository at this point in the history
  • Loading branch information
saokiritoni authored Oct 30, 2024
1 parent 2d8d1bd commit 40f21dd
Showing 1 changed file with 23 additions and 30 deletions.
53 changes: 23 additions & 30 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,55 +8,48 @@ on:

jobs:
build:

runs-on: ubuntu-latest
runs-on: self-hosted
permissions:
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

# Configure Gradle for optimal use in GiHub Actions, including caching of downloaded dependencies.
# See: https://github.com/gradle/actions/blob/main/setup-gradle/README.md
# Gradle ์„ค์ •
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5

- name: Build with Gradle Wrapper
run: ./gradlew build

# Docker build & Push
# Docker ์ด๋ฏธ์ง€ ๋นŒ๋“œ ๋ฐ ๋ฐฐํฌ
- name: Docker build & push to Docker hub
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_USERNAME }}/docker-test .
docker push ${{ secrets.DOCKER_USERNAME }}/docker-test
# EC2 ๋ฐฐํฌ
- name: Docker image pull & Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test:latest
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps --filter 'status=exited' -a -q)
sudo docker image prune -a -f
sudo docker run -d --restart unless-stopped --log-driver=syslog -p 8080:8080 \
-e DB_URL=${{ secrets.DB_URL }} \
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
-e REDIS_HOST=${{ secrets.REDIS_HOST }} \
-e REDIS_PORT=${{ secrets.REDIS_PORT }} \
-e SMTP_HOST=${{ secrets.SMTP_HOST }} \
-e SMTP_PORT=${{ secrets.SMTP_PORT }} \
-e SMTP_USERNAME=${{ secrets.SMTP_USERNAME }} \
-e SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }} \
${{ secrets.DOCKER_USERNAME }}/docker-test:latest
# Docker ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰
- name: Deploy Docker container
run: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/docker-test:latest
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps --filter 'status=exited' -a -q)
sudo docker image prune -a -f
sudo docker run -d --restart unless-stopped --log-driver=syslog -p 8080:8080 \
-e DB_URL=${{ secrets.DB_URL }} \
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \
-e REDIS_HOST=${{ secrets.REDIS_HOST }} \
-e REDIS_PORT=${{ secrets.REDIS_PORT }} \
-e SMTP_HOST=${{ secrets.SMTP_HOST }} \
-e SMTP_PORT=${{ secrets.SMTP_PORT }} \
-e SMTP_USERNAME=${{ secrets.SMTP_USERNAME }} \
-e SMTP_PASSWORD=${{ secrets.SMTP_PASSWORD }} \
${{ secrets.DOCKER_USERNAME }}/docker-test:latest

0 comments on commit 40f21dd

Please sign in to comment.