Skip to content

Merge pull request #236 from fixadate/chomyoung #44

Merge pull request #236 from fixadate/chomyoung

Merge pull request #236 from fixadate/chomyoung #44

Workflow file for this run

name: Build and Deploy (Push)
on:
push:
branches: [ 'main' ]
paths:
- '**'
permissions: write-all
env:
PROJECT_NAME: fixadate
BUCKET_NAME: fixadate-bucket
CODE_DEPLOY_APP_NAME: fixadate
DEPLOYMENT_GROUP_NAME: fixadate_codedeploy_group
SPRING_PROFILES_ACTIVE: prod
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: Set YML AND Credentials
run: |
mkdir -p src/main/resources
echo "${{ secrets.FIXADATE_CREDENTIALS }}" | base64 --decode > src/main/resources/application.yml
find src
- name: SET Credentials
uses: jsdaniell/[email protected]
with:
name: "credentials.json"
json: ${{ secrets.FIXADATE_CREDENTIALS_JSON }}
dir: './src/main/resources/'
- name: Build with Gradle
run: ./gradlew build
# - name: Publish Test Results
# uses: EnricoMi/publish-unit-test-result-action@v2
# if: always()
# with:
# files: build/test-results/test/TEST-*.xml
- name: Make Zip File
run: zip -qq -r ./$GITHUB_SHA.zip .
shell: bash
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_FIXAMATE_ACCESSKEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_FIXAMATE_ACCESSKEY }}
aws-region: ap-northeast-2
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip
- name: Code Deploy To EC2 instance
run: |
aws deploy create-deployment \
--application-name $CODE_DEPLOY_APP_NAME \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name $DEPLOYMENT_GROUP_NAME \
--s3-location bucket=$BUCKET_NAME,bundleType=zip,key=$PROJECT_NAME/$GITHUB_SHA.zip