Skip to content

infra : prod github actions workflow 추가 #1

infra : prod github actions workflow 추가

infra : prod github actions workflow 추가 #1

Workflow file for this run

name: prod CI&CD to Cloud
on:
push:
branches:
- prod
env:
HOST: ${{ secrets.AWS_PROD_HOST }}
KEY: ${{ secrets.AWS_PROD_KEY }}
DOCKERHUB_REPO: ${{ secrets.DOCKERHUB_PROD_REPO }}
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ DOCKERHUB_PASSWORD }}

Check failure on line 12 in .github/workflows/prod-CD.yml

View workflow run for this annotation

GitHub Actions / prod CI&CD to Cloud

Invalid workflow file

The workflow is not valid. .github/workflows/prod-CD.yml (Line: 12, Col: 23): Unrecognized named-value: 'DOCKERHUB_PASSWORD'. Located at position 1 within expression: DOCKERHUB_PASSWORD .github/workflows/prod-CD.yml (Line: 74, Col: 9): Unexpected value 'script'
APPLICATION_DIR: src/main/resources
APPLICATION_PROD: ${{ secrets.APPLICATION_PROD }}
jobs:
build:
name: CI & CD
runs-on: ubuntu-latest
steps:
# (0) 시간 출력
- name: Get Current Time
uses: 1466587594/get-current-time@v2
id: current-time
with:
format: YYYY-MM-DDTHH:mm:ss
timezone: 'Asia/Seoul'
- name: Print Current Time
run: echo "Current Time=${{steps.current-time.outputs.formattedTime}}"
shell: bash
# (1) 기본 체크아웃
- name: Checkout
uses: actions/checkout@v3
# (2) JDK 11 세팅
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'temurin'
# (3) 환경변수 파일 생성
- name: Copy properties
run: echo $APPLICATION_PROD | base64 --decode > $APPLICATION_DIR/application-prod.yml
# (4) gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# (5) Gradle build (Test 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: clean build -x test
# (6) Docker 이미지 빌드
- name: Docker build & push to docker repo
run: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker build -f Dockerfile -t $DOCKERHUB_REPO/ssafsound-app .
docker push $DOCKERHUB_REPO/ssafsound-app
# (7) ssh 접속 후 docker compose up
- name: Deploy to server
uses: appleboy/ssh-action@master
id: deploy
with:
host: $HOST
username: ubuntu
key: $KEY
envs: GITHUB_SHA
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull $DOCKERHUB_REPO/ssafsound-app
docker-compose up -d
docker image prune -f