remove: Repository Test 삭제 #34
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: issue-tracking-system CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Set up environment variables | |
run: | | |
echo "DB_URL=${{ secrets.DB_URL }}" >> $GITHUB_ENV | |
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> $GITHUB_ENV | |
echo "DB_PASSWORD=${{ secrets.DB_PASSWORD }}" >> $GITHUB_ENV | |
- name: Build with Gradle | |
run: ./gradlew build | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build Docker image | |
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/issue-tracking-system:latest . | |
- name: Push Docker image | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/issue-tracking-system:latest | |
- name: Deploy to EC2 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ubuntu | |
key: ${{ secrets.EC2_KEY }} | |
script: | | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/issue-tracking-system:latest | |
docker stop issue-tracking-system || true | |
docker rm issue-tracking-system || true | |
docker run -d -p 80:8080 --name issue-tracking-system \ | |
-e DB_URL=${{ secrets.DB_URL }} \ | |
-e DB_USERNAME=${{ secrets.DB_USERNAME }} \ | |
-e DB_PASSWORD=${{ secrets.DB_PASSWORD }} \ | |
${{ secrets.DOCKERHUB_USERNAME }}/issue-tracking-system:latest | |
sleep 10 | |
docker logs issue-tracking-system |