Skip to content

Commit

Permalink
[FEAT] #26 - Edit ci and create cd to dev server workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
gmlwo530 committed Aug 24, 2021
1 parent 6bede0a commit c371689
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 4 deletions.
68 changes: 68 additions & 0 deletions .github/workflows/cd-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CD Dev

on: [ pull_request ]

jobs:
ci:
runs-on: ubuntu-latest
env:
S3_BUCKET_NAME: jampick-server
S3_FOLDER_NAME: dev
services:
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: jampick
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
ports:
- "3306:3306"
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v2
with:
java-version: '11'
distribution: 'adopt'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@e6e38bacfdf1a337459f332974bb2327a31aaf4b

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build -x test

- name: Make zip file
run: zip -qq -r ./$GITHUB_SHA.zip .

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Upload to S3
env:
AWS_REGION: ${{ secrets.AWS_REGION }}
run: aws s3 cp --region $AWS_REGION ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$S3_FOLDER_NAME/$GITHUB_SHA.zip

- name: Code Deploy
run: aws deploy create-deployment --application-name jampick-app --deployment-config-name CodeDeployDefault.OneAtATime --deployment-group-name jampick-group --s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=$S3_FOLDER_NAMEyes/$GITHUB_SHA.zip

- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ jobs:
image: mysql:5.7
env:
MYSQL_DATABASE: jampick
MYSQL_USER: user
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: mysql
MYSQL_ROOT_PASSWORD: ${{ secrets.MYSQL_ROOT_PASSWORD }}
ports:
- "3306:3306"
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=10
Expand All @@ -36,7 +34,7 @@ jobs:
restore-keys: |
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build
run: ./gradlew build -x test
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
Expand Down

0 comments on commit c371689

Please sign in to comment.