deploy #1
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: deploy | |
| on: | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - run: touch ./src/main/resources/application.properties | |
| - run: echo "${{ secrets.production }}" > ./src/main/resources/application.properties | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: 17 | |
| distribution: 'temurin' | |
| cache: 'gradle' | |
| # Gradle wrapper 파일 실행 권한주기 | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| # Gradle Cache 추가 | |
| - name: Cache Gradle packages | |
| id: cache-npm | |
| uses: actions/cache@v3 | |
| with: | |
| path: | | |
| ~/.gradle/caches | |
| ~/.gradle/wrapper | |
| key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
| restore-keys: | | |
| ${{ runner.os }}-gradle- | |
| - if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
| name: List the state of node modules | |
| continue-on-error: true | |
| run: npm list | |
| - name: Get Github action IP | |
| id: ip | |
| uses: haythem/public-ip@v1.3 | |
| - name: Setting environment variables | |
| run: | | |
| echo "AWS_DEFAULT_REGION=ap-northeast-2" >> $GITHUB_ENV | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v2 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ap-northeast-2 | |
| - name: Setup and execute Gradle 'build' task | |
| uses: gradle/gradle-build-action@v2 | |
| with: | |
| arguments: clean build | |
| cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }} | |
| - name: Upload JAR | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: artifact | |
| path: build/libs/baascore-0.0.1-SNAPSHOT.jar | |
| deploy: | |
| needs: build | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download JAR | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: artifact | |
| #Deploy the artifact (JAR) into AWS Beanstalk | |
| - name: Deploy to EB | |
| uses: einaregilsson/beanstalk-deploy@v21 | |
| with: | |
| aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| #aws_session_token: ${{ secrets.AWS_SESSION_TOKEN }} | |
| use_existing_version_if_available: false | |
| application_name: Crews-BE-Core | |
| environment_name: Crews-BE-Core-env | |
| version_label: ${{github.SHA}} | |
| region: ap-northeast-2 | |
| deployment_package: baascore-0.0.1-SNAPSHOT.jar |