Skip to content

Commit

Permalink
๐Ÿ”ง ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ •
Browse files Browse the repository at this point in the history
  • Loading branch information
waterfogSW committed Sep 22, 2024
1 parent 92a4e28 commit 0e265cb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 12 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/cd-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ env:
jobs:
deploy:
runs-on: ubuntu-latest
environment: dev

steps:
- name: Checkout code
Expand Down Expand Up @@ -61,35 +62,73 @@ jobs:
fi
echo "Image found in ECR"
- name: Generate Dockerrun.aws.json
- name: Generate Dockerrun.aws.json with environment variables
env:
VERSION: ${{ steps.determine-version.outputs.VERSION }}
REGISTRY_URL: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }}
VARS_CONTEXT: ${{ toJson(vars) }}
SECRETS_CONTEXT: ${{ toJson(secrets) }}
run: |
VERSION=${{ steps.determine-version.outputs.VERSION }}
cat > Dockerrun.aws.json << EOF
{
# ์‹œ์ž‘ ๋ถ€๋ถ„ ์ž‘์„ฑ
echo '{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "${{ steps.login-ecr.outputs.registry }}/$ECR_REPOSITORY:$VERSION",
"Name": "'"$REGISTRY_URL"'/'"$ECR_REPOSITORY"':'"$VERSION"'",
"Update": "true"
},
"Ports": [
{
"ContainerPort": 8080,
"HostPort": 80
}
],
"Environment": [' > Dockerrun.aws.json
# GitHub Secrets ์ถ”๊ฐ€
FIRST_VAR=true
echo "$SECRETS_CONTEXT" | jq -r 'to_entries[] | select(.key | test("^AWS_") | not) | "\(.key)=\(.value)"' | while IFS='=' read -r SECRET_KEY SECRET_VALUE; do
if [ "$FIRST_VAR" = false ]; then
echo ',' >> Dockerrun.aws.json
fi
echo ' {
"Name": "'"$SECRET_KEY"'",
"Value": "'"$SECRET_VALUE"'"
}' >> Dockerrun.aws.json
FIRST_VAR=false
done
# GitHub Vars ์ถ”๊ฐ€
echo "$VARS_CONTEXT" | jq -r 'to_entries[] | "\(.key)=\(.value)"' | while IFS='=' read -r VAR_KEY VAR_VALUE; do
if [ "$FIRST_VAR" = false ]; then
echo ',' >> Dockerrun.aws.json
fi
echo ' {
"Name": "'"$VAR_KEY"'",
"Value": "'"$VAR_VALUE"'"
}' >> Dockerrun.aws.json
FIRST_VAR=false
done
# JSON ๋งˆ๋ฌด๋ฆฌ
echo '
]
}
EOF
}' >> Dockerrun.aws.json
- name: Create deployment package
run: |
zip -r deploy.zip Dockerrun.aws.json
- name: Deploy to Elastic Beanstalk
uses: einaregilsson/beanstalk-deploy@v21
uses: einaregilsson/beanstalk-deploy@v22
with:
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
application_name: ${{ env.EB_APPLICATION_NAME }}
environment_name: ${{ env.EB_ENVIRONMENT_NAME }}
version_label: ${{ steps.determine-version.outputs.VERSION }}-${{ github.sha }}
region: ${{ env.AWS_REGION }}
deployment_package: Dockerrun.aws.json
deployment_package: deploy.zip
use_existing_version_if_available: true

- name: Deployment result
Expand Down
9 changes: 9 additions & 0 deletions bootstrap/api/src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ spring:
- application
- persistence
- sms
docker:
compose:
enabled: false
---
spring:
config:
Expand All @@ -16,3 +19,9 @@ spring:
docker:
compose:
file: ./bootstrap/api/compose.yaml
enabled: true
---
spring:
config:
activate:
on-profile: dev
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/3days?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
username: root
password: secret
url: jdbc:mysql://${DB_HOST:localhost:3306}/${DB_NAME:3days}?serverTimezone=Asia/Seoul&characterEncoding=UTF-8
username: ${DB_USERNAME:root}
password: ${DB_PASSWORD:secret}
flyway:
enabled: true
locations: classpath:db/migration

0 comments on commit 0e265cb

Please sign in to comment.