Skip to content

update: ci test

update: ci test #55

Workflow file for this run

name: Dev-CD
permissions:
contents: read
on:
pull_request:
types:
- closed
branches:
- 'dev'
env:
AWS_REGION: ap-northeast-2
ECR_REPOSITORY: katj-dev
ECS_SERVICE: service-katj-dev
ECS_CLUSTER: katj-cluster-ecs-dev
CONTAINER_NAME: katj-dev
ECS_TASK_DEFINITION: katj-dev.json
jobs:
ci-cd-dev:
if: github.event.pull_request.merged == true
environment: dev
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
# 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-
# src application 파일 생성

Check failure on line 46 in .github/workflows/dev-cicd.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/dev-cicd.yml

Invalid workflow file

You have an error in your yaml syntax on line 46
- name: make application.yml
run: |
# mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.YML }}" > ./application.yml
shell: bash
- name: make Test application.yml
run: |
mkdir ./src/test/resources
cd ./src/test/resources
touch ./application-test.yml
echo "${{ secrets.TEST_YML }}" > ./application-test.yml
shell: bash
# 권한 부여
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# 빌드 진행
- name: Build with Gradle
run: ./gradlew build
# jar 파일 upload
- name: Upload Jar file
uses: actions/upload-artifact@v3
with:
name: jar-file
path: build/libs/*.jar
deploy_to_dev:
needs: ci-cd-dev
environment: dev
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- 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: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
# jar file download
- name: Download Jar file
uses: actions/download-artifact@v3
with:
name: jar-file
path: build/libs/
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: latest
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_TASK_DEFINITION }}
container-name: ${{ env.CONTAINER_NAME }}
image: ${{ steps.build-image.outputs.image }}
- name: Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.task-def.outputs.task-definition }}
service: ${{ env.ECS_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true
slack_noti:
name: Slack_notification
runs-on: ubuntu-latest
needs: deploy_to_dev
steps:
- name: action-slack
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: www-be
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took
if_mention: failure,cancelled
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} # required
if: always() # Pick up events even if the job fails or is canceled.