Skip to content

[HOTFIX] Development Server CD - Appspec Resource 누락 점검 #6

[HOTFIX] Development Server CD - Appspec Resource 누락 점검

[HOTFIX] Development Server CD - Appspec Resource 누락 점검 #6

Workflow file for this run

name: Continuous Deployment for SOPT makers Authentication Development Server
on:
workflow_dispatch:
push:
branches: [ dev ]
jobs:
build-and-push-image:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: ✅ Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'corretto'
cache: gradle
- name: 🤝 Grant execute permission for gradlew
run: chmod +x ./gradlew
shell: bash
- name: 🔒 Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: ⚙️ Create Property File
run: |
touch ./gradle.properties
echo "${{ secrets.PROPERTY_GRADLE }}" >> ./gradle.properties
- name: 🧱 Build Image and Push to ECR
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ECR_REPO: ${{ secrets.AWS_ECR_REPO_DEV }}
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws
docker build --build-arg PROFILE=dev -t $AWS_ECR_REPO .
docker tag $AWS_ECR_REPO:latest public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest
docker push public.ecr.aws/$AWS_ACCOUNT_ID/$AWS_ECR_REPO:latest
create-deploy:
needs: build-and-push-image
runs-on: ubuntu-22.04
steps:
- name: 🔒 Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: 🔑 Copy Key File
env:
REGION: ${{ secrets.AWS_REGION }}
APPLE_KEY: ${{ secrets.APPLE_KEY }}
JWT_PUBLIC_KEY: ${{ secrets.JWT_PUBLIC_KEY }}
JWT_PRIVATE_KEY: ${{ secrets.JWT_PRIVATE_KEY }}
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
run: |
mkdir ./pem
mkdir ./key
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/static/$JWT_PUBLIC_KEY ./pem/$JWT_PUBLIC_KEY
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/static/$JWT_PRIVATE_KEY ./pem/$JWT_PRIVATE_KEY
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/static/$APPLE_KEY ./key/$APPLE_KEY
- name: 📝 Copy Script File
env:
REGION: ${{ secrets.AWS_REGION }}
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
S3_ENV_FILE_NAME: ${{ secrets.ENV_FILE_NAME_DEV }}
run: |
mkdir ./script
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/script/deploy.sh ./script/deploy.sh
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/script/switch.sh ./script/switch.sh
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/script/valid.sh ./script/valid.sh
aws s3 cp --region $REGION \
s3://$S3_BUCKET/dev/$S3_ENV_FILE_NAME ./application.env
- name: 📁 Make files to zip
run: |
pwd
ls -l
zip -r ./$GITHUB_SHA.zip ./script ./pem ./key ./appspec.yml ./application.env
shell: bash
- name: 🚀 Upload Property Zip to S3 and Create Code Deploy
env:
REGION: ${{ secrets.AWS_REGION }}
DEPLOY_APPLICATION: ${{ secrets.AWS_DEPLOY_APPLICATION }}
DEPLOY_GROUP: ${{ secrets.AWS_DEPLOY_GROUP_DEV }}
S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
run: |
aws s3 cp --region $REGION ./$GITHUB_SHA.zip s3://$S3_BUCKET/dev/deploy/$GITHUB_SHA.zip
aws deploy create-deployment --application-name $DEPLOY_APPLICATION \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name $DEPLOY_GROUP \
--s3-location bucket=$S3_BUCKET,bundleType=zip,key=dev/deploy/$GITHUB_SHA.zip