HotFix : flyway중간 버전 추가 #94
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
name: Java CI with Gradle | |
on: | |
pull_request: | |
branches: [ "main" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env : | |
working-directory: ./ | |
APPLICATION: ${{ secrets.APPLICATION_PROD }} | |
steps: | |
# Get Public IP using curl | |
- name: Get Public IP | |
id: ip | |
run: echo "::set-output name=ipv4::$(curl -s https://checkip.amazonaws.com)" | |
# Display GitHub IP | |
- name: Display GitHub IP | |
run: echo "GitHub IP is ${{ steps.ip.outputs.ipv4 }}" | |
# Configure AWS Credentials | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-northeast-2 | |
# Add github ip to AWS SecurityGroup | |
- name: Add GitHub IP to AWS RDS | |
run: | | |
aws ec2 authorize-security-group-ingress --group-id ${{ secrets.AWS_RDS_SG_ID }} --protocol tcp --port 3306 --cidr ${{ steps.ip.outputs.ipv4 }}/32 | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'adopt' | |
- name: Cache Gradle packages | |
uses: actions/cache@v2 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Create application.yml | |
run: | | |
echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml | |
- name: Create resources directory | |
run: mkdir -p ./src/main/resources ./src/test/resources | |
- name: Create application-test.yml | |
run: | | |
echo "${{env.APPLICATION_TEST}}" > ./src/test/resources/application-test.yml | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
working-directory: ${{ env.working-directory }} | |
- name: Build with Gradle | |
run: ./gradlew build | |
working-directory: ${{ env.working-directory }} | |
- name: Cleanup Gradle Cache | |
if: ${{ always() }} | |
run: | | |
rm -f ~/.gradle/caches/modules-2/modules-2.lock | |
rm -f ~/.gradle/caches/modules-2/gc.properties | |
- name: Remove IP FROM security group RDS | |
if: ${{ always() }} | |
run: | | |
aws ec2 revoke-security-group-ingress --group-id ${{ secrets.AWS_RDS_SG_ID }} --protocol tcp --port 3306 --cidr ${{ steps.ip.outputs.ipv4 }}/32 |