-
Notifications
You must be signed in to change notification settings - Fork 31
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
1 parent
041d0f8
commit bffa4d8
Showing
3 changed files
with
122 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,109 @@ | ||
name: BMI application workflow | ||
on: | ||
pull_request: | ||
branches: [ master ] | ||
paths: | ||
- 'src/**' | ||
- '.github/workflows/app-workflow.yml' | ||
push: | ||
branches: [ master ] | ||
paths: | ||
- 'src/**' | ||
- '.github/workflows/app-workflow.yml' | ||
|
||
jobs: | ||
project-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'corretto' | ||
|
||
- name: Set up the Maven dependencies caching | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: Install Maven dependencies | ||
run: mvn clean install | ||
|
||
- name: Run tests | ||
run: mvn clean --batch-mode --update-snapshots verify | ||
|
||
docker-build: | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
runs-on: ubuntu-latest | ||
needs: | ||
- project-build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 21 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '21' | ||
distribution: 'corretto' | ||
|
||
- name: Cache Maven packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: ~/.m2 | ||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} | ||
restore-keys: ${{ runner.os }}-m2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Log into the Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Scrape build info | ||
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Build and push | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: Dockerfile | ||
push: true | ||
labels: ${{ steps.meta.outputs.labels }} | ||
# tags: hendisantika/bmi:${{ steps.meta.outputs.tags }} | ||
# tags: ${{ steps.meta.outputs.tags }} | ||
# tags: hendisantika/bmi:latest | ||
tags: hendisantika/bmi:${{ github.run_number }} | ||
build-args: | | ||
GIT_VERSION_TAG=${{ env.RELEASE_VERSION }} | ||
GIT_COMMIT_MESSAGE=${{ github.event.head_commit.message }} | ||
GIT_VERSION_HASH=${{ github.sha }} | ||
deploy: | ||
if: ${{ github.ref == 'refs/heads/master' }} | ||
runs-on: ubuntu-latest | ||
needs: | ||
- docker-build | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Add Server key | ||
run: | | ||
touch key.txt && echo "${{ secrets.SERVER_KEY }}" > key.txt | ||
chmod 600 key.txt | ||
- name: Deploy the application | ||
env: | ||
SERVER_HOST: ${{ secrets.SERVER_HOST }} | ||
SERVER_PORT: ${{ secrets.SERVER_PORT }} | ||
SERVER_USER: ${{ secrets.SERVER_USERNAME }} | ||
run: | | ||
set -e | ||
./deploy.sh |
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
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
events { | ||
} | ||
|
||
http { | ||
server { | ||
listen 80; | ||
location / { | ||
proxy_pass http://app:9000; | ||
} | ||
} | ||
} |