Skip to content

missing double quote on cicd yaml security username password #6

missing double quote on cicd yaml security username password

missing double quote on cicd yaml security username password #6

name: CI/CD FOR TEST_SERVER
on:
push:
branches:
- develop
env:
DOCKERHUB_REPOSITORY: fontory-test-server
jobs:
skip_check:
name: checking skip ci
runs-on: ubuntu-latest
outputs:
should_run: ${{ steps.check.outputs.should_run }}
steps:
- name: Check for [skip ci] in commit message
id: check
run: |
if echo "${{ github.event.head_commit.message }}" | grep -iq "\[skip ci\]"; then
echo "should_run=false" >> $GITHUB_OUTPUT
else
echo "should_run=true" >> $GITHUB_OUTPUT
fi
CI:
name: Continuous Integration
needs: skip_check
if: needs.skip_check.outputs.should_run == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Get short SHA
id: slug
run: echo "sha7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Discord Webhook Action
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.TEST_SERVER_DISCORD_WEBHOOK_URL }}
content: |
New Commit[${{ steps.slug.outputs.sha7 }}] detected on branch ${{ github.ref_name }}
Commit Link: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup MySQL
uses: mirromutth/[email protected]
with:
host port: 3308
mysql database: 'TESTDB'
mysql user: 'fontory'
mysql password: 'fontoryPW'
- name: Setup Redis
uses: supercharge/[email protected]
with:
redis-version: 6
- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
- name: Generate application.properties
run: |
echo "api.server.url=${{ secrets.TEST_SERVER_API_URL }}" >> ./src/main/resources/application-prod.properties
echo "commit.hash=${{ steps.slug.outputs.sha7 }}" >> ./src/main/resources/application-prod.properties
echo "spring.datasource.url=jdbc:mariadb://${{ secrets.DATASOURCE_DB_URL }}:3306/FONTORY?characterEncoding=UTF-8&serverTimezone=Asia/Seoul" >> ./src/main/resources/application-prod.properties
echo "spring.datasource.username=${{ secrets.DATASOURCE_DB_USERNAME }}" >> ./src/main/resources/application-prod.properties
echo "spring.datasource.password=${{ secrets.DATASOURCE_DB_PASSWORD }}" >> ./src/main/resources/application-prod.properties
echo "spring.data.redis.host=${{ secrets.REDIS_URL }}" >> ./src/main/resources/application-prod.properties
echo "spring.security.user.name=${{ secrets.SPRING_SECURITY_USER_NAME }}" >> ./src/main/resources/application-prod.properties
echo "spring.security.user.password=${{ secrets.SPRING_SECURITY_USER_PASSWORD }}" >> ./src/main/resources/application-prod.properties
echo "jwt.access-secret-key=${{ secrets.JWT_SECRETKEY }}" >> ./src/main/resources/application.properties
echo "jwt.refresh-secret-key=${{ secrets.JWT_REFESH_SECRETKEY }}" >> ./src/main/resources/application.properties
echo "jwt.provide-secret-key=${{ secrets.JWT_PROVIDE_SECRETKEY }}" >> ./src/main/resources/application.properties
echo "jwt.font-create-server-secret-key=${{ secrets.JWT_FONT_CREATE_SERVER_SECRETKEY }}" >> ./src/main/resources/application.properties
echo "spring.security.oauth2.client.registration.google.client-id=${{ secrets.OAUTH2_GOOGLE_CLIENT_ID }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.security.oauth2.client.registration.google.client-secret=${{ secrets.OAUTH2_GOOGLE_CLIENT_SECRET }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.security.oauth2.client.registration.google.scope=${{ secrets.OAUTH2_GOOGLE_SCOPE }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.security.oauth2.client.registration.google.redirect-uri=${{ secrets.TEST_OAUTH2_GOOGLE_REDIRECT_URI }}" >> ./src/main/resources/application-infrastructure.properties
printf "%s\n" "${{ secrets.TEST_OAUTH2_NAVER_PROPERTIES }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.region.static=${{ secrets.AWS_REGION }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.credentials.access-key=${{ secrets.AWS_ACCESS_KEY }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.credentials.SECRET-key=${{ secrets.AWS_SECRET_KEY }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.profile-image=${{ secrets.AWS_BUCKET_NAME_PROFILE_IMAGE }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.profile-image.prefix=${{ secrets.AWS_BUCKET_NAME_PROFILE_IMAGE_PREFIX }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.font-paper=${{ secrets.AWS_BUCKET_NAME_FONT_PAPER }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.font-paper.prefix=${{ secrets.AWS_BUCKET_NAME_FONT_PAPER_PREFIX }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.font=${{ secrets.AWS_BUCKET_NAME_FONT }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.s3.bucket.font.prefix=${{ secrets.AWS_BUCKET_NAME_FONT_PREFIX }}" >> ./src/main/resources/application-infrastructure.properties
echo "spring.cloud.aws.sqs.queue-name=${{ secrets.AWS_FONT_CREATE_QUEUE_NAME }}" >> ./src/main/resources/application-infrastructure.properties
echo "discord.webhook.error-url=${{ secrets.TEST_SERVER_DISCORD_WEBHOOK_ERROR_URL }}" >> ./src/main/resources/application-infrastructure.properties
echo "url.base=https://fontory.co.kr" >> ./src/main/resources/application-infrastructure.properties
echo "coolsms.api-key=${{ secrets.COOLSMS_API_KEY }}" >> ./src/main/resources/application-infrastructure.properties
echo "coolsms.api-secret=${{ secrets.COOLSMS_API_SECRET }}" >> ./src/main/resources/application-infrastructure.properties
echo "coolsms.phone-number=${{ secrets.COOLSMS_PHONE_NUMBER }}" >> ./src/main/resources/application-infrastructure.properties
echo "coolsms.base-url=${{ secrets.COOLSMS_BASE_URL }}" >> ./src/main/resources/application-infrastructure.properties
- name: Build with Gradle Wrapper
# run: ./gradlew test -i
run: ./gradlew build
- name: Upload jar file to Artifact
uses: actions/upload-artifact@v4
with:
name: jar_files
path: build/libs/*.jar
- name: Upload Dockerfile to Artifact
uses: actions/upload-artifact@v4
with:
name: Dockerfile
path: ./Dockerfile
CD_Delivery:
name: Delivery
needs: CI
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Download jar file from Artifact
uses: actions/download-artifact@v4
with:
name: jar_files
path: build/libs
- name: Download Dockerfile file from Artifact
uses: actions/download-artifact@v4
with:
name: Dockerfile
path: ./
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Get short SHA
id: slug
run: echo "sha7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Build, tag, and push image to DockerHub
id: build-image
env:
USERNAME: ${{ secrets.DOCKER_USERNAME }}
IMAGE_TAG: ${{ steps.slug.outputs.sha7 }}
run: |
docker build -t $USERNAME/$DOCKERHUB_REPOSITORY:$IMAGE_TAG -t $USERNAME/$DOCKERHUB_REPOSITORY:latest .
docker push $USERNAME/$DOCKERHUB_REPOSITORY --all-tags
echo "image=$USERNAME/$DOCKERHUB_REPOSITORY:$IMAGE_TAG&latest" >> $GITHUB_OUTPUT
CD_Deploy:
name: Deploy
needs: CD_Delivery
runs-on: ubuntu-latest
steps:
- name: Get short SHA
id: slug
run: echo "sha7=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_OUTPUT
- name: Executing remote ssh commands
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.TEST_SERVER_REMOTE_IP }}
username: ${{ secrets.TEST_SERVER_REMOTE_USER }}
key: ${{ secrets.TEST_SERVER_REMOTE_PRIVATE_KEY }} # ec2 instance pem key
passphrase: ${{ secrets.TEST_SERVER_SSH_PASSPHRASE }}
port: ${{ secrets.TEST_SERVER_REMOTE_SSH_PORT }} # 접속포트
script: | # 실행할 스크립트
cd /Users/jeonghoon-lee/workspace/fontory-spring/rolling_update
./rolling-update.sh
- name: Discord Webhook Action
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.TEST_SERVER_DISCORD_WEBHOOK_URL }}
content: |
:o: Server successfully updated!
Commit: [${{ github.sha }}]
Branch: ${{ github.ref_name }}
Commit Link: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
failure_notification:
name: Failure Notification
runs-on: ubuntu-latest
needs: [CI, CD_Delivery, CD_Deploy]
if: failure()
steps:
- name: Discord Webhook Action on Failure
uses: tsickert/[email protected]
with:
webhook-url: ${{ secrets.TEST_SERVER_DISCORD_WEBHOOK_URL }}
content: |
:x: A job failed in the CI/CD pipeline!
Commit: [${{ github.sha }}]
Branch: ${{ github.ref_name }}
Commit Link: https://github.com/${{ github.repository }}/commit/${{ github.sha }}
GitHub Action Link: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
Please check the logs for more details.