Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions .github/workflows/patch-1_kanchi-first-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy JAR app to Azure Web App - kanchi-first-app

on:
push:
branches:
- patch-1
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'

- name: Build with Maven
run: mvn clean install

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
permissions:
id-token: write #This is required for requesting the JWT

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: java-app

- name: Login to Azure
uses: azure/login@v1
with:
client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_8FAFF7E8956A418493A6D6955A82E145 }}
tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_9D7AB54362434A5F8B6AB31AE16F7BFB }}
subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_BCAF6DA67F674F76B60CB02E057E288C }}

- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'kanchi-first-app'
slot-name: 'Production'
package: '*.jar'

85 changes: 45 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
<img align="left" width="48" height="48" src="./spring-boot-logo.jpg">
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

# Spring Boot Application Example
name: Build and deploy JAR app to Azure Web App - kanchi-first-app

[![Build Status](https://travis-ci.org/mertakdut/Spring-Boot-Sample-Project.svg?branch=master)](https://travis-ci.org/mertakdut/Spring-Boot-Sample-Project)
[![Coverage Status](https://coveralls.io/repos/github/mertakdut/Spring-Boot-Sample-Project/badge.svg?branch=master)](https://coveralls.io/github/mertakdut/Spring-Boot-Sample-Project?branch=master)
on:
push:
branches:
- master
workflow_dispatch:

This is a sample Java / Maven / Spring Boot application which provides RESTful services. It can be used as a starter project. Currently it is designed to work as [this project](https://github.com/mertakdut/React-Sample-Project)'s backend.
jobs:
build:
runs-on: ubuntu-latest

## Installation Instructions
You can import the project as a maven application to your favorite IDE. I made my tests by using eclipse jee-2018-12.

If lombok gets in your way, by referring [this answer](https://stackoverflow.com/a/22332248/4130569), you can install lombok by its jar file.
steps:
- uses: actions/checkout@v4

## To run the application
Use one of the several ways of running a Spring Boot application. Below are just three options:
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '11'

1. Build using maven goal (or by using maven wrapper): `mvn clean package` and execute the resulting artifact as follows `java -jar BankApplicationBackend-0.0.1-SNAPSHOT.jar` or
2. On Unix/Linux based systems: run `mvn clean package` then run the resulting jar as any other executable `./BankApplicationBackend-0.0.1-SNAPSHOT.jar`
3. Run as a [Docker](https://www.docker.com/) container.
1) Clone the repository.
2) cd to project root directory.
3) `docker build -t demo/bankapp .`
* If you get a `./mvnw not found` error, just run `mvn -N io.takari:maven:wrapper -Dmaven=3.5.3` while in the root directory of the project.
4) `docker run --expose 8080 -p 8080:8080 demo/bankapp`
- name: Build with Maven
run: mvn clean install

## To test the application
1. Create a user with /api/user/create url.
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v3
with:
name: java-app
path: '${{ github.workspace }}/target/*.jar'

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: java-app

`$ curl -X POST localhost:8080/api/user/create -d "{\"username\": \"yourUsername\", \"password\": \"yourPassword\", \"tcno\": \"12512561125\"}" -H "Content-Type:application/json"`
You'll get a response as in below.

`{"username":"yourUsername","tcno":"12512561125"}`
2. Generate an access token by /api/login url.

`$ curl -H "Content-Type: application/json" -X POST -d "{\"username\": \"yourUsername\", \"password\": \"yourPassword\"}" http://localhost:8080/api/login`

You'll be getting an access token similar to this.

`eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ5b3VyVXNlcm5hbWUiLCJleHAiOjE1NTI0NDMzNjZ9.0WSCg4vaP7BVeJz8tQnL3s-BYjBB6UWXlQKCZHm1_zqEVIiA8_71Ni7tbPDm2DbW-Qc_fPP9CQF1jKcRC9njFQ`

3. Use the token to access content available to all authenticated users, through the RESTful API.

Http.Get request example:
`curl -i -H "Accept: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ5b3VyVXNlcm5hbWUiLCJleHAiOjE1NTI0NDMzNjZ9.0WSCg4vaP7BVeJz8tQnL3s-BYjBB6UWXlQKCZHm1_zqEVIiA8_71Ni7tbPDm2DbW-Qc_fPP9CQF1jKcRC9njFQ" -X GET http://localhost:8080/api/user/find/all`

Http.Post request example:
`curl -H "Content-Type: application/json" -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJ5b3VyVXNlcm5hbWUiLCJleHAiOjE1NTI0NDMzNjZ9.0WSCg4vaP7BVeJz8tQnL3s-BYjBB6UWXlQKCZHm1_zqEVIiA8_71Ni7tbPDm2DbW-Qc_fPP9CQF1jKcRC9njFQ" -X POST -d "{\"username\": \"yourUsername\", \"buying\": \"true\", \"currency\": \"USD\", \"amount\": \"250\"}" http://localhost:8080/api/transaction/create`
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'kanchi-first-app'
slot-name: 'production'
package: '*.jar'
publish-profile: ${{ secrets.AzureAppService_PublishProfile_5daef4ff31cc463ab8d12b62bbf5721d }}
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<name>BankApplicationBackend</name>

<properties>
<java.version>1.8</java.version>
<java.version>11</java.version>
</properties>

<dependencies>
Expand Down Expand Up @@ -79,6 +79,11 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.6.201602180812</version>
Expand Down