Azure WebApp Github CI/CD yaml 파일 작성
# 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 - springboot-kms
on:
push:
branches:
- master
workflow_dispatch:
jobs:
# 1. BUILD 진행
build:
runs-on: ubuntu-latest # 빌드환경
steps:
- uses: actions/checkout@v2
# [기본 템플릿] Java 환경설정
- name: Set up Java version
uses: actions/setup-java@v1
with:
java-version: '17'
# 디렉토리 변경
- name: Change directory to spring-petclinic
run: cd spring-petclinic
# 권한부여 추가
- name: Grant execute permission for gradlew
run: chmod +x gradlew
working-directory: spring-petclinic
# Gradle 빌드 수정
- name: Build with Gradle
run : |
cd spring-petclinic # 해당 디렉토리로 이동
./gradlew build -x test # Gradle 빌드 실행
# Azure 인증 추가 : 레포지토리 > Setting >
# Secrets and variables > Actions >
# New repository secret 클릭해서 생성
- name: Azure Login
uses: azure/login@v1
with:
creds: $
# 아티팩트 업로드 (경로 수정)
- name: Upload artifact for deployment job
uses: actions/upload-artifact@v2
with:
name: java-app
# path: '$/target/*.jar'
path: '$/spring-petclinic/build_JAR'
# 2. 배포
deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: $
steps:
# 아티팩트 다운로드(다운로드 경로 추가)
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: java-app
path: '$/spring-petclinic/build_JAR'
# 배포
- name: Deploy to Azure Web App
id: deploy-to-webapp
uses: azure/webapps-deploy@v2
with:
app-name: 'springboot-kms'
slot-name: 'Production'
publish-profile: $
# package: '*.jar'
package: '$/spring-petclinic/build_JAR/*.jar'