Skip to content

[SWM-296] Feat : add github action execution yaml file #1

[SWM-296] Feat : add github action execution yaml file

[SWM-296] Feat : add github action execution yaml file #1

Workflow file for this run

name: Java CI with Gradle
on:
push:
branches:
- main
- feat/#99/implement-cicd(swm-296)
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'adopt'
## gradlew 의 권한을 줍니다.
- name: Grant execute permission for gradlew
run: chmod +x gradlew
## gradle build
- name: Build with Gradle
run: ./gradlew clean build --debug
## 이미지 태그에 시간 설정을 하기위해서 현재 시간을 가져옴
- name: Get current time
uses: 1466587594/get-current-time@v2
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}}"
## AWS에 로그인
- 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: ap-northeast-2
## ECR에 로그인
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon ECR
run: |
docker build -t sroom-repo:${{steps.current-time.outputs.formattedTime}} .
docker tag sroom-repo:${{steps.current-time.outputs.formattedTime}} 224066583965.dkr.ecr.ap-northeast-2.amazonaws.com/sroom-repo:${{steps.current-time.outputs.formattedTime}}
docker push 224066583965.dkr.ecr.ap-northeast-2.amazonaws.com/sroom-repo:${{steps.current-time.outputs.formattedTime}}