Skip to content

Commit

Permalink
Create gradle-publish.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnsugyeong authored Oct 1, 2023
1 parent d6498d7 commit a1177ec
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/gradle-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle

# env 설정
env:
S3_BUCKET_NAME: waggle-bucket
PROJECT_NAME: Waggle
CODE_DEPLOY_APP_NAME: waggle
CODE_DEPLOY_GROUP_NAME: waggle-deploy

name: CI/CD using Github Actions & AWS CodeDeploy

on:
release:
types: [push]
push:
branches: [master]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
# JDK setting - github actions에서 사용할 JDK 설정
- name: Checkout
uses: actions/checkout@v3

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

# gradle caching - 빌드 시간 향상
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
# Build with Gradle
- name: Build with Gradle
run: ./gradlew build -x test

# 빌드 날짜 설정
- name: Get current time
uses: 1466587594/get-current-time@v2 # (9)
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"

- name: Show Current Time
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" # (10)
shell: bash

# zip 파일 생성
- name: Make zip file
run: zip -r ./$PROJECT_NAME.zip . # (12)
shell: bash

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1 #(13)
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ap-northeast-2

- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$PROJECT_NAME.zip s3:

- name: Code Deploy
run: aws deploy create-deployment --application-name $CODE_DEPLOY_APP_NAME --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name $CODE_DEPLOY_GROUP_NAME --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$PROJECT_NAME.zip

0 comments on commit a1177ec

Please sign in to comment.