Merge pull request #222 from Team-TenTen/chore/flyway #140
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: LinkHub CI/CD | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Java | |
uses: actions/setup-java@v2 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Build linkhub.jar | |
run: ./gradlew build -x test | |
- name: Set up Docker | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push Docker image | |
run: | | |
docker build -t ${{ secrets.LINKHUB_IMAGE }}:application-v${GITHUB_RUN_NUMBER} . | |
docker tag ${{ secrets.LINKHUB_IMAGE }}:application-v${GITHUB_RUN_NUMBER} ${{ secrets.LINKHUB_IMAGE }}:latest | |
docker push ${{ secrets.LINKHUB_IMAGE }}:application-v${GITHUB_RUN_NUMBER} | |
docker push ${{ secrets.LINKHUB_IMAGE }}:latest | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@v0.1.10 | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
password: ${{ secrets.PASSWORD }} | |
script: | | |
cd LinkHub-BE | |
chmod +x deploy.sh | |
./deploy.sh |