From aa818386e70e191dd961c4f751f882e7d2efc3f8 Mon Sep 17 00:00:00 2001 From: thalals Date: Mon, 19 Feb 2024 17:51:31 +0900 Subject: [PATCH] update git action yml & add appspec file for code deploy --- .github/workflows/gradle-publish.yml | 19 ++++++++++--------- appspec.yml | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 9 deletions(-) create mode 100644 appspec.yml diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index 0250d53..3bb1af4 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -12,9 +12,10 @@ on: push: branches: - main -# env: -# DEPLOY_FILE_NAME: deployfile-`date +%Y%m%d.%H%M%S` - +env: + AWS_CODE_DEPLOY_APPLICATION: THT-ChatServer-GitAction + AWS_CODE_DEPLOY_GROUP: THT-ChatServer-GitAction-SingleServer + jobs: build: runs-on: ubuntu-latest @@ -50,16 +51,16 @@ jobs: timezoneLinux: "Asia/Seoul" timezoneMacos: "Asia/Seoul" timezoneWindows: "Seoul Standard Time" - + - name: make env now date id: now run: echo "date=`date +%Y%m%d_%H:%M:%S`" >> "$GITHUB_OUTPUT" - + - name: Make Zip File id: file run: zip -qq -r ./deployfile-${{ steps.now.outputs.date }}.zip . shell: bash - + - name: AWS credential uses: aws-actions/configure-aws-credentials@v1 with: @@ -70,9 +71,9 @@ jobs: - name: Upload to AWS S3 run: aws s3 cp ./deployfile-${{ steps.now.outputs.date }}.zip s3://${{ secrets.S3_DEPLOY_BUCKET }}/deployfile-${{ steps.now.outputs.date }}.zip -# - name: Deploy EC2 -# run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=$AWS_S3_BUCKET,key=cicdtest/$GITHUB_SHA.zip,bundleType=zip -# + - name: Deploy EC2 + run: aws deploy create-deployment --application-name ${{ env.AWS_CODE_DEPLOY_APPLICATION }} --deployment-config-name CodeDeployDefault.AllAtOnce --deployment-group-name ${{ env.AWS_CODE_DEPLOY_GROUP }} --s3-location bucket=${{ secrets.S3_DEPLOY_BUCKET }},key=/deployfile-${{ steps.now.outputs.date }}.zip,bundleType=zip + # # The USERNAME and TOKEN need to correspond to the credentials environment variables used in # # the publishing section of your build.gradle # - name: Publish to GitHub Packages diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..5098311 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,17 @@ +version: 0.0 +os: linux + +files: + - source: / + destination: /home/ubuntu/deploy + +permissions: + - object: /home/ubuntu/deploy/ + owner: ubuntu + group: ubuntu + +hooks: + AfterInstall: + - location: /start_server.sh + timeout: 60 + runas: ubuntu \ No newline at end of file