Update docker-compose-gateway.yml #72
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: Java CI with Gradle | |
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
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' | |
- 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: 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: 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 -f docker-compose-gateway.yml up -d |