|
| 1 | +name: Swacademy Prod CI/CD |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [closed] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + if: github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'main' |
| 12 | + |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v2 |
| 17 | + |
| 18 | + - name: Set up JDK 17 |
| 19 | + uses: actions/setup-java@v3 |
| 20 | + with: |
| 21 | + java-version: 17 |
| 22 | + distribution: 'adopt' |
| 23 | + |
| 24 | + - name: Grant execute permission for gradlew |
| 25 | + run: chmod +x ./gradlew |
| 26 | + shell: bash |
| 27 | + |
| 28 | + |
| 29 | + - name: Build with Gradle |
| 30 | + run: ./gradlew clean build -x test |
| 31 | + shell: bash |
| 32 | + |
| 33 | + |
| 34 | + - name: Get current time |
| 35 | + uses: 1466587594/get-current-time@v2 |
| 36 | + id: current-time |
| 37 | + with: |
| 38 | + format: YYYY-MM-DDTHH-mm-ss |
| 39 | + utcOffset: "+09:00" |
| 40 | + |
| 41 | + - name: Show Current Time |
| 42 | + run: echo "CurrentTime=$" |
| 43 | + shell: bash |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + - name: Generate deployment package |
| 49 | + run: | |
| 50 | + mkdir -p deploy |
| 51 | + cp build/libs/*.jar deploy/application.jar |
| 52 | + cp Procfile deploy/Procfile |
| 53 | + cp -r .ebextensions-prod deploy/.ebextensions |
| 54 | + cp -r .platform deploy/.platform |
| 55 | + cd deploy && zip -r deploy.zip . |
| 56 | + |
| 57 | +
|
| 58 | + - name: Debug Beanstalk Deploy |
| 59 | + run: | |
| 60 | + echo "AWS_ACTION_ACCESS_KEY_ID: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }}" |
| 61 | + echo "AWS_ACTION_SECRET_ACCESS_KEY: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }}" |
| 62 | +
|
| 63 | + - name: Beanstalk Deploy |
| 64 | + uses: einaregilsson/beanstalk-deploy@v20 |
| 65 | + with: |
| 66 | + aws_access_key: ${{ secrets.AWS_ACTION_ACCESS_KEY_ID }} |
| 67 | + aws_secret_key: ${{ secrets.AWS_ACTION_SECRET_ACCESS_KEY }} |
| 68 | + application_name: swacademy-prod |
| 69 | + environment_name: Swacademy-prod-env |
| 70 | + version_label: github-action-${{ steps.current-time.outputs.formattedTime }} |
| 71 | + region: ap-northeast-2 |
| 72 | + deployment_package: deploy/deploy.zip |
| 73 | + wait_for_deployment: false |
| 74 | + |
| 75 | + |
0 commit comments