Merge branch 'dev' #8
This file contains hidden or 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: RUNNECT-PROD-CD | |
| # ν΄λΉ workflowκ° μΈμ μ€νλ κ²μΈμ§μ λν νΈλ¦¬κ±°λ₯Ό μ§μ | |
| # pushμμ μ€ν | |
| on: | |
| push: | |
| branches: [ main ] # main branchλ‘ push λ λ μ€νλ©λλ€. | |
| env: | |
| S3_BUCKET_NAME: runnect-prod-bucket | |
| jobs: | |
| build: | |
| name: Code deployment | |
| # μ€ν νκ²½ | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1) μν¬νλ‘μ° μ€ν μ κΈ°λ³Έμ μΌλ‘ 체ν¬μμ νμ | |
| - name: checkout | |
| uses: actions/checkout@v3 | |
| # 2) JDK 11λ²μ μ€μΉ, λ€λ₯Έ JDK λ²μ μ μ¬μ©νλ€λ©΄ μμ | |
| - name: Set up JDK 11 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: '11' | |
| distribution: 'temurin' | |
| # 3) νκ²½λ³μ νμΌ μμ± | |
| - name: make application.properties νμΌ μμ± | |
| run: | | |
| ## create application.yml | |
| mkdir ./src/main/resources | |
| cd ./src/main/resources | |
| # application.yml νμΌ μμ± | |
| touch ./application.yml | |
| # GitHub-Actions μμ μ€μ ν κ°μ application.yml νμΌμ μ°κΈ° | |
| echo "${{ secrets.RUNNECT_PROD_APPLICATION }}" >> ./application.yml | |
| # application.yml νμΌ νμΈ | |
| cat ./application.yml | |
| shell: bash | |
| # μ΄ μν¬νλ‘μ°λ gradle build | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle # μ€μ application build ν μ€νΈ μ μΈ | |
| run: ./gradlew build -x test | |
| # λλ ν 리 μμ± | |
| - name: Make Directory | |
| run: mkdir -p deploy | |
| # Jar νμΌ λ³΅μ¬ | |
| - name: Copy Jar | |
| run: cp ./build/libs/*.jar ./deploy | |
| # appspec.yml νμΌ λ³΅μ¬ | |
| - name: Copy appspec.yml | |
| run: cp appspec.yml ./deploy | |
| # script files λ³΅μ¬ | |
| - name: Copy script | |
| run: cp ./scripts/*.sh ./deploy | |
| - name: Make zip file | |
| run: zip -r ./runnect_prod_server.zip ./deploy | |
| shell: bash | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_PROD_ACCESS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_PROD_SECRET_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Upload to S3 | |
| run: aws s3 cp --region ap-northeast-2 ./runnect_prod_server.zip s3://$S3_BUCKET_NAME/ | |
| # Deploy | |
| - name: Deploy | |
| env: | |
| AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PROD_ACCESS_KEY }} | |
| AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PROD_SECRET_KEY }} | |
| run: | |
| aws deploy create-deployment | |
| --application-name runnect-prod-codedeploy | |
| --deployment-group-name runnect-prod-codedeploy-group | |
| --file-exists-behavior OVERWRITE | |
| --s3-location bucket=runnect-prod-bucket,bundleType=zip,key=runnect_prod_server.zip | |
| --region ap-northeast-2 |