-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
52 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,64 @@ | ||
name: Java CI with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
push: | ||
branches: [ "master" ] | ||
pull_request: | ||
branches: [ "master" ] | ||
|
||
permissions: | ||
contents: read | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Make application.yml | ||
run: | | ||
mkdir -p src/main/resources | ||
echo "$APPLICATION" > src/main/resources/application.yml | ||
env: | ||
APPLICATION: ${{ secrets.APPLICATION }} | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Make application.yml | ||
run: | | ||
mkdir -p src/main/resources | ||
echo "$APPLICATION" > src/main/resources/application.yml | ||
env: | ||
APPLICATION: ${{ secrets.APPLICATION }} | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Docker build | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t app . | ||
docker tag app ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
docker push ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
- name: Copy docker-compose.yml to remote server | ||
uses: appleboy/scp-action@master | ||
with: | ||
username: ec2-user | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
port: ${{ secrets.PORT }} | ||
source: "./docker-compose-gateway.yml" | ||
target: "/home/ec2-user/" | ||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
- name: Docker build | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t app . | ||
docker tag app ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
docker push ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ec2-user | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
# Pull the latest Docker image | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
docker image prune -a -f | ||
docker-compose -f /home/ec2-user/docker-compose-gateway.yml up -d | ||
- name: docker-compose.yml | ||
uses: appleboy/scp-action@master | ||
with: | ||
username: ec2-user | ||
host: ${{ secrets.HOST }} | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
port: ${{ secrets.PORT }} | ||
source: "./docker-compose-gateway.yml" | ||
target: "/home/ec2-user/" | ||
|
||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ec2-user | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
# Pull the latest Docker image | ||
docker pull ${{ secrets.DOCKER_USERNAME }}/apigateway:latest | ||
docker image prune -a -f | ||
docker stop apigateway | ||
docker-compose-gateway up -d |