Skip to content

Update AccountRepository.kt #63

Update AccountRepository.kt

Update AccountRepository.kt #63

Workflow file for this run

name: Docker Publish
on:
push:
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
# 1. Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
- name: Debug workspace
run: ls ./
# 2. Set up JDK 17
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
# 3. Cache Gradle dependencies
- name: Cache Gradle dependencies
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# 4. Grant execute permission to gradlew
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
# 5. Build the application with Gradle
- name: Build with Gradle
run: ./gradlew build
# 6. Log in to Docker Hub
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# 7. Build and tag the Docker image
- name: Build Docker image
run: |
docker build --build-arg JAR_FILE=build/libs/*.jar -t endermaru/22-5-team1-server:latest .
docker tag endermaru/22-5-team1-server:latest endermaru/22-5-team1-server:${{ github.sha }}
# 8. Push the Docker image to Docker Hub
- name: Push Docker image
run: |
docker push endermaru/22-5-team1-server:latest
docker push endermaru/22-5-team1-server:${{ github.sha }}
deploy:
runs-on: ubuntu-latest
needs: build-and-push
steps:
# 1. Checkout the repository
- name: Checkout repository
uses: actions/checkout@v3
- name: Check workspace files
run: ls -al ${GITHUB_WORKSPACE}
# 1. Send docker-compose.yml to EC2 server
- name: Copy docker-compose files to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
source: "./docker-compose*.yml"
target: "/home/ubuntu"
debug: true
# 2. Deploy to EC2 via SSH
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_PRIVATE_KEY }}
script: |
cd ~/app
docker-compose --env-file .env -f docker-compose.yml -f docker-compose.prod.yml down
docker-compose --env-file .env -f docker-compose.yml -f docker-compose.prod.yml pull
docker-compose --env-file .env -f docker-compose.yml -f docker-compose.prod.yml up --build -d
debug: true