Skip to content

[Feat] update dev server deploy script #462

[Feat] update dev server deploy script

[Feat] update dev server deploy script #462

Workflow file for this run

name: Deploy to Test Instance
on:
workflow_dispatch:
inputs:
logLevel:
description: 'Log level'
required: true
default: 'warning'
type: choice
options:
- info
- warning
- debug
repository_dispatch:
types: [deploy-to-test-event]
push:
branches: [ develop ]
pull_request:
types: [ edited ]
env:
SPRING_PROFILES_ACTIVE: dev
ECR_APP_NAME: ${{ secrets.ECR_APP_NAME }}-${{ env.SPRING_PROFILES_ACTIVE }}

Check failure on line 24 in .github/workflows/cd-to-dev.yml

View workflow run for this annotation

GitHub Actions / Deploy to Test Instance

Invalid workflow file

The workflow is not valid. .github/workflows/cd-to-dev.yml (Line: 24, Col: 17): Unrecognized named-value: 'env'. Located at position 1 within expression: env.SPRING_PROFILES_ACTIVE .github/workflows/cd-to-dev.yml (Line: 25, Col: 13): Unrecognized named-value: 'env'. Located at position 1 within expression: env.ECR_APP_NAME
ECR_REPO: ${{ secrets.ECR_HOST }}/${{ env.ECR_APP_NAME }}
GREEN_SERVER_IMAGE: ${{ env.ECR_REPO }}
BLUE_SERVER_IMAGE: ${{ env.ECR_REPO }}
jobs:
build:
name: CD Pipeline
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up JDK 1.17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: 'Check Java Version'
run: |
java --version
echo 'ecr repo is $ECR_REPO'
- name: 'Configure AWS credentials'
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID__TEAM_PLAYGROUND }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY__TEAM_PLAYGROUND }}
aws-region: ap-northeast-2
- name: 'Get application.yml from AWS S3'
run: |
aws s3 cp \
--region ap-northeast-2 \
s3://sopt-makers-internal/dev/deploy/application-dev.yml src/main/resources/application.yml
- name: 'Get key from AWS S3'
run: |
aws s3 cp \
--region ap-northeast-2 \
s3://sopt-makers-internal/dev/deploy/${{ secrets.APPLE_KEY }} src/main/resources/static/${{ secrets.APPLE_KEY }}
- name: 'Build with Gradle'
run: |
chmod +x ./gradlew
./gradlew clean build -x test
shell: bash
- name: 'Configure Docker Build Environment'
uses: docker/[email protected]
- name: 'Login to ECR'
run: |
aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin ${{ secrets.ECR_HOST }}
- name: 'Docker Image Build & Push'
run: |
docker buildx build --platform linux/arm64 -f Dockerfile -t $ECR_REPO .
docker push $ECR_REPO
- name: 'Send docker-compose.yml to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
source: "./docker-compose.yml"
target: "/home/ec2-user/"
- name: 'Send deploy script to EC2 Instance'
uses: appleboy/scp-action@master
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
source: "./scripts/deploy.sh"
target: "/home/ec2-user/app/"
- name: 'Get current time'
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH-mm-ss
utcOffset: "+09:00"
- name: 'Docker Container Run'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.DEV_RELEASE_SERVER_IP }}
username: ${{ secrets.RELEASE_SERVER_USER }}
key: ${{ secrets.DEV_RELEASE_SERVER_KEY }}
script: |
cd ~
sudo docker pull ${{ secrets.ECR_REPO }}
sudo chmod +x ./deploy.sh
cp ./app/scripts/deploy,sh
./deploy.sh
docker image prune -f