diff --git a/.github/workflows/CICD.yml b/.github/workflows/CICD.yml index 88f328791..6ca7c234c 100644 --- a/.github/workflows/CICD.yml +++ b/.github/workflows/CICD.yml @@ -1,64 +1,38 @@ -#name: bucket-back CICD -#on: -# push: -# branches: [ "main" ] -# pull_request: -# branches: [ "main" ] -# -#env: -# PROJECT_NAME: bucket-back -# BUCKET_NAME: team-02-bucket -# CODE_DEPLOY_APP_NAME: team-02-codeDeployApplication -# DEPLOYMENT_GROUP_NAME: team-02-bucketBack -# -#jobs: -# deploy: -# runs-on: ubuntu-latest -# steps: -# - uses: actions/checkout@v3 -# -# - name: Set up JDK 17 -# uses: actions/setup-java@v3 -# with: -# java-version: '17' -# distribution: 'temurin' -# - name: Grant execute permission for gradlew -# run: chmod +x ./gradlew -# shell: bash -# -# - name: Set YML -# run: | -# mkdir -p bucketback-api/src/main/resources -# echo "${{ secrets.APPLICATION_YML }}" | base64 --decode > bucketback-api/src/main/resources/application.yml -# echo "${{ secrets.APPLICATION_API_YML }}" | base64 --decode > bucketback-api/src/main/resources/application-api.yml -# find bucketback-api/src -# mkdir -p bucketback-domain/src/main/resources -# echo "${{ secrets.APPLICATION_DOMAIN_YML }}" | base64 --decode > bucketback-domain/src/main/resources/application-domain.yml -# find bucketback-domain/src -# mkdir -p bucketback-infrastructure/src/main/resources -# echo "${{ secrets.APPLICATION_INFRA_YML }}" | base64 --decode > bucketback-infrastructure/src/main/resources/application-infra.yml -# find bucketback-infrastructure/src -# -# - name: Build and Test -# run: ./gradlew build test -# -# - name: Make Zip File # zip 파일 생성 -# 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_ACCESS_KEY_ID }} -# aws-secret-access-key: ${{ secrets.AWS_PRIVATE_ACCESS_KEY }} -# 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 +name: Java CI with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build-docker-image: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Build with Gradle + uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 + with: + arguments: clean bootJar + + - name: docker image build + run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo . + + - name: docker login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: docker Hub push + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/github-actions-demo