Skip to content

Commit

Permalink
KL-184/deploy: apply makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
ohhamma committed Oct 8, 2024
1 parent b4f3e3f commit 9592bc8
Showing 1 changed file with 28 additions and 24 deletions.
52 changes: 28 additions & 24 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build and Deploy using Docker Compose
name: Build and Deploy using Makefile and Docker Compose

on:
push:
Expand All @@ -8,28 +8,36 @@ on:
workflow_dispatch:

jobs:
build-deploy:
build-and-deploy:
runs-on: ubuntu-latest
environment: dev
strategy:
matrix:
java-version: [ 17 ]
distribution: [ "zulu" ]

steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v2
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v3
with:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}
gradle-version: 8.8

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Create .env file
run: |
touch .env
echo "${{ secrets.ENV }}" > .env
shell: bash

- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Build with Makefile
run: make build

- name: Run tests
run: make test

- name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -38,21 +46,17 @@ jobs:
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and Push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64/v3
push: true
tags: ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
run: |
make up
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_IMAGE_NAME }}:latest
- name: Copy compose.yaml to EC2
- name: Copy compose.yaml and .env to EC2
uses: appleboy/scp-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
source: "compose.yaml"
source: "compose.yaml,.env"
target: "~/"

- name: Deploy to EC2
Expand Down

0 comments on commit 9592bc8

Please sign in to comment.