Procfile edit #67
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: tuna-study-backend | |
permissions: | |
contents: read | |
pull-requests: write | |
on: | |
push: | |
branches: ["main", "develop"] | |
pull_request: | |
branches: ["main", "develop"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
shell: bash | |
- name: Install envsubst | |
run: sudo apt-get install -y gettext | |
- name: Create application.yml.template | |
run: | | |
mkdir -p src/main/resources | |
cat > src/main/resources/application.yml.template <<EOL | |
server: | |
port: 5000 | |
tomcat: | |
uri-encoding: UTF-8 | |
spring: | |
application: | |
name: bean-tuna | |
main: | |
allow-bean-definition-overriding: true | |
datasource: | |
driver-class-name: org.mariadb.jdbc.Driver | |
url: jdbc:mariadb://\${RDS_HOSTNAME}:\${RDS_PORT}/\${RDS_DB_NAME}?serverTimezone=Asia/Seoul | |
username: \${RDS_USERNAME} | |
password: \${RDS_PASSWORD} | |
jpa: | |
hibernate: | |
ddl-auto: update | |
show-sql: true | |
properties: | |
hibernate: | |
dialect: org.hibernate.dialect.MariaDBDialect | |
format_sql: true | |
use_sql_comments: true | |
database-platform: org.hibernate.dialect.MySQL8Dialect | |
generate-ddl: on | |
default_batch_fetch_size: 1000 | |
batch: | |
job: | |
enabled: false | |
jdbc: | |
initialize-schema: always | |
schema: classpath:org/springframework/batch/core/schema-mariadb.sql | |
cloud: | |
aws: | |
credentials: | |
access-key: \${AWS_ACCESS_KEY_ID} | |
secret-key: \${AWS_SECRET_ACCESS_KEY} | |
region: | |
static: ap-northeast-2 | |
auto: false | |
s3: | |
bucket: \${SPRING_CLOUD_AWS_S3_BUCKET} | |
region: \${SPRING_CLOUD_AWS_S3_REGION} | |
access-key: \${AWS_ACCESS_KEY_ID} | |
secret-key: \${AWS_SECRET_ACCESS_KEY} | |
sns: | |
region: ap-northeast-1 | |
EOL | |
- name: Set Yaml | |
run: | | |
envsubst < src/main/resources/application.yml.template > src/main/resources/application.yml | |
cat src/main/resources/application.yml | |
env: | |
RDS_HOSTNAME: ${{ secrets.RDS_HOSTNAME }} | |
RDS_PORT: ${{ secrets.RDS_PORT }} | |
RDS_DB_NAME: ${{ secrets.RDS_DB_NAME }} | |
RDS_USERNAME: ${{ secrets.RDS_USERNAME }} | |
RDS_PASSWORD: ${{ secrets.RDS_PASSWORD }} | |
SPRING_CLOUD_AWS_S3_BUCKET: ${{ secrets.SPRING_CLOUD_AWS_S3_BUCKET }} | |
SPRING_CLOUD_AWS_S3_REGION: ${{ secrets.SPRING_CLOUD_AWS_S3_REGION }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
shell: bash | |
- name: Get current time | |
uses: 1466587594/get-current-time@v2 | |
id: current-time | |
with: | |
format: YYYY-MM-DDTHH-mm-ss | |
utcOffset: "+09:00" | |
- name: Show Current Time | |
run: echo "CurrentTime=${{steps.current-time.outputs.formattedTime}}" | |
shell: bash | |
- name: Generate deployment package | |
run: | | |
mkdir -p deploy | |
JAR_FILE=$(ls build/libs/*.jar | head -n 1) | |
if [ -f "$JAR_FILE" ]; then | |
cp "$JAR_FILE" deploy/application.jar | |
else | |
echo "JAR file not found!" | |
exit 1 | |
fi | |
if [ -f Procfile ]; then | |
cp Procfile deploy/Procfile | |
else | |
echo "Procfile not found!" | |
exit 1 | |
fi | |
if [ -d .ebextensions ]; then | |
cp -r .ebextensions deploy/.ebextensions | |
else | |
echo ".ebextensions directory not found!" | |
exit 1 | |
fi | |
if [ -d .platform ]; then | |
cp -r .platform deploy/.platform | |
else | |
echo ".platform directory not found!" | |
exit 1 | |
fi | |
cd deploy && zip -r deploy.zip . | |
shell: bash | |
- name: Upload application version to S3 | |
run: | | |
aws s3 cp deploy/deploy.zip s3://elasticbeanstalk-ap-northeast-2-033089156253/deploy/deploy.zip | |
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: Create new Elastic Beanstalk application version | |
run: | | |
aws elasticbeanstalk create-application-version \ | |
--application-name bean-tuna \ | |
--version-label github-action-${{steps.current-time.outputs.formattedTime}} \ | |
--source-bundle S3Bucket=elasticbeanstalk-ap-northeast-2-033089156253,S3Key=deploy/deploy.zip | |
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: Update Elastic Beanstalk environment | |
run: | | |
aws elasticbeanstalk update-environment \ | |
--environment-name Bean-tuna-env \ | |
--version-label github-action-${{steps.current-time.outputs.formattedTime}} | |
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 |