Merge pull request #235 from ranunclulus/Feat/#225-vote-confirm-and-kill #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Chatfia Dev CI/CD | ||
on: | ||
pull_request: | ||
types: [ closed ] | ||
workflow_dispatch: # (2).수동 실행도 가능하도록 | ||
permissions: | ||
contents: read | ||
jobs: | ||
secrets: inherit | ||
build: | ||
runs-on: ubuntu-latest # (3).OS환경 | ||
secrets: inherit | ||
if: github.event.pull_request.merged == true && (github.event.pull_request.base.ref == 'main' || github.event.pull_request.base.ref == 'develop') | ||
# 환경변수 | ||
env: | ||
NAVER_MAIL_PASSWORD: ${{ secrets.NAVER_MAIL_PASSWORD }} | ||
NAVER_MAIL_USERNAME: ${{ secrets.NAVER_MAIL_USERNAME }} | ||
REDIS_HOST: ${{ secrets.REDIS_HOST }} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
KAKAO_SNS_APP_KEY: ${{ secrets.KAKAO_SNS_APP_KEY }} | ||
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | ||
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 # 코드 check out | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 # 자바 설치 | ||
distribution: 'adopt' | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash # 권한 부여 | ||
- name: Build with Gradle | ||
run: ./gradlew clean build -x test | ||
shell: bash # build 시작 | ||
- name: Get current-time | ||
uses: gerred/actions/current-time@master | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" # (8).build 시점의 시간 확보 | ||
- name: Show Current Time | ||
run: echo "CurrentTime=${{ steps.current-time.outputs.time }}" | ||
shell: bash # (9).확보한 시간 보여 주기 | ||
- name: Test with Gradle | ||
run: ./gradlew --info test # (10).test 시작 | ||
- name: Get current time test | ||
uses: gerred/actions/current-time@master | ||
id: current-time-test | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" # (11).test 시점의 시간 확보 | ||
- name: Show Current Time test | ||
run: echo "CurrentTime=$"{{ steps.current-time.outputs.time }}" | ||
shell: bash # (12).확보한 시간 보여 주기 | ||
- name: Run string replace | ||
uses: frabert/replace-string-action@master | ||
id: format-time | ||
with: | ||
pattern: '[:\.]+' | ||
string: "${{ steps.current-time-test.outputs.time }}" | ||
replace-with: '-' | ||
flags: 'g' | ||
# 도커 로그인 + 빌드 | ||
- name: Docker build | ||
run: | | ||
docker login -u ${{ env.DOCKERHUB_USERNAME }} -p ${{ env.DOCKERHUB_TOKEN }} | ||
docker build -t springles . | ||
docker tag springles chatpiaspringles/springles:latest | ||
docker push chatpiaspringles/springles:latest | ||
- name: Generate deployment package | ||
run: | | ||
mkdir -p deploy | ||
cp build/libs/*.jar deploy/application.jar | ||
cp Procfile deploy/Procfile | ||
cp -r .ebextensions deploy/.ebextensions | ||
cp -r .platform deploy/.platform | ||
cd deploy && zip -r deploy.zip . | ||
- name: Beanstalk Deploy | ||
uses: einaregilsson/beanstalk-deploy@v21 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: springles-dev | ||
environment_name: Springles-dev-env | ||
version_label: "the-simple-engineer-deployment-${{ steps.format-time.outputs.replaced }}" | ||
region: ap-northeast-2 | ||
# deployment_package: docker-compose.yml | ||
deployment_package: deploy/deploy.zip | ||
wait_for_environment_recovery: 60 | ||
# use_existing_version_if_available: true |