[#47] Github Actions에 application.yml에 Github Secrets의 값을 끼워 넣어주는 step 추가 #1
Workflow file for this run
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
# 1. 워크 플로 이름 지정 | |
name: HappinesSQL CI/CD | |
# 2. 워크플로가 시작될 조건 지정 | |
on: | |
pull_request: | |
types: [ closed ] | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest # 3. 실행 환경 지정 | |
if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'develop' | |
# 4. 실행 스텝 지정 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 # 자바 설치 | |
distribution: 'adopt' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash # 권한 부여 | |
- name: Set Environment | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: ./src/main/resources/application.yml | |
env: | |
cloud.aws.credentials.access-key: ${{ secrets.AWS_S3_ACCESS_KEY }} | |
cloud.aws.credentials.secret-key: ${{ secrets.AWS_S3_SECRET_KEY }} | |
spring.datasource.url: ${{ secrets.DB_URL }} | |
spring.datasource.username: ${{ secrets.DB_USER }} | |
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | |
- name: Build with Gradle | |
run: ./gradlew clean build -x test | |
shell: bash # build 시작 | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" # build 시점의 시간확보 | |
- name: Show Current Time | |
run: echo "CurrentTime=$" | |
shell: bash # 확보한 시간 보여주기 | |
- name: Generate deployment package | |
run: | | |
mkdir -p deploy | |
cp build/libs/*.jar deploy/application.jar | |
cp Procfile deploy/Procfile | |
cp -r .ebextensions deploy/.ebextensions | |
cp -r .platform deploy/.platform | |
cd deploy && zip -r deploy.zip . | |
- name: Beanstalk Deploy | |
uses: einaregilsson/beanstalk-deploy@v20 | |
with: | |
aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }} | |
aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }} | |
application_name: happinessql-dev | |
environment_name: Happinessql-dev-env | |
version_label: github-action-${{ steps.current-time.outputs.formattedTime }} | |
region: ap-northeast-2 | |
deployment_package: deploy/deploy.zip | |
wait_for_deployment: false |