Skip to content

Feature/add aop

Feature/add aop #122

Workflow file for this run

name: Java Test CI with Gradle
on: [pull_request]
jobs:
build:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
# application.yml 파일 복사
- name: Copy application.yml
env:
APPLICATION_YML_FILE: ${{ secrets.TEST_APPLICATION_YML }}
run: echo $APPLICATION_YML_FILE | base64 --decode > src/main/resources/application-test.yml
# recipeapp-key.json 파일 복사
- name: Copy recipeapp-key.json
env:
RECIPEAPP_KEY_FILE: ${{ secrets.RECIPEAPP_KEY }}
run: echo $RECIPEAPP_KEY_FILE | base64 --decode > src/main/resources/recipeapp-key.json
# secret 파일 디렉토리 생성
- name: Create secret directory
run: mkdir src/main/java/com/recipe/app/src/config/secret
# Secret.java 파일 복사
- name: Copy Secret.java
env:
SECRET_JAVA_FILE: ${{ secrets.SECRET_JAVA }}
run: echo $SECRET_JAVA_FILE | base64 --decode > src/main/java/com/recipe/app/src/config/secret/Secret.java
- name: Get Public IP
id: publicip
run: |
response=$(curl -s canhazip.com)
echo "ip='$response'" >> "$GITHUB_OUTPUT"
- name: Setting environment variables
run: |
echo "AWS_DEFAULT_REGION=ap-northeast-2" >> $GITHUB_ENV
echo "AWS_SG_NAME=launch-wizard-1" >> $GITHUB_ENV
- 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
- name: Add Github Actions IP to Security group
run: |
aws ec2 authorize-security-group-ingress --group-name ${{ env.AWS_SG_NAME }} --protocol tcp --port 3306 --cidr ${{ steps.publicip.outputs.ip }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-2
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Test with Gradle
run: ./gradlew test
- name: Remove Github Actions IP from security group
run: |
aws ec2 revoke-security-group-ingress --group-name ${{ env.AWS_SG_NAME }} --protocol tcp --port 3306 --cidr ${{ steps.publicip.outputs.ip }}/32
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ap-northeast-2