thalals is learning GitHub Actions #9
Workflow file for this run
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created | |
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle | |
name: THT API SERVER | |
run-name: ${{ github.actor }} is learning GitHub Actions | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- main | |
env: | |
AWS_CODE_DEPLOY_APPLICATION: THT-ApiServer-GitAction | |
AWS_CODE_DEPLOY_GROUP: THT-ApiServer-GitAction-SingleServer | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'app') | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: CheckOut | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GIT_TOKEN }} | |
submodules: true | |
- name: Set up JDK 17 | |
uses: | |
actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
settings-path: ${{ github.workspace }} # location for the settings.xml file | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@ec92e829475ac0c2315ea8f9eced72db85bb337a # v3.0.0 | |
- name : set time zone | |
uses: szenius/[email protected] | |
with: | |
timezoneLinux: "Asia/Seoul" | |
timezoneMacos: "Asia/Seoul" | |
timezoneWindows: "Seoul Standard Time" | |
- name: Cache with Gradle | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ github.repository }}-gradle-${{ hashFiles('**/*.gradle*') }} | |
restore-keys: | | |
${{ github.repository }}-gradle- | |
- name: Build with Gradle | |
run: ./gradlew clean tht-apis:clean tht-apis:build | |
- 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: | |
aws-region: ${{ secrets.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- 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=${{ secrets.S3_DEPLOY_BUCKET }},key=deployfile-${{ steps.now.outputs.date }}.zip,bundleType=zip |