Fix: deleting .named('test')
near tasks in build.gradle
#11
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: CI-CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: Set up PostgreSQL | |
uses: Daniel-Marynicz/[email protected] | |
with: | |
postgres_user: ${{ secrets.DB_USER }} | |
postgres_db: ${{ secrets.DB_NAME }} | |
postgres_password: ${{ secrets.DB_PASSWORD }} | |
- name: Build with Gradle | |
run: ./gradlew build --scan | |
- name: Build Docker image | |
run: docker build -t blogue-dev:latest . | |
- name: Save Docker image to a tar file | |
run: docker save blogue-dev:latest -o blogue.tar | |
- name: Copy Docker image to EC2 | |
uses: appleboy/[email protected] | |
with: | |
source: blogue.tar | |
target: /home/ubuntu/blogue.tar | |
host: ${{ secrets.EC2_HOST }} | |
username: ubuntu | |
key: ${{ secrets.EC2_SSH_KEY }} | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: SSH to EC2 and load Docker image | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ubuntu | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
docker load -i /home/ubuntu/blogue.tar | |
docker stop blogue || true | |
docker rm blogue || true | |
docker run -d --name blogue -p 80:8080 blogue-dev:latest |