Skip to content

Commit

Permalink
chore: 워크플로에서 set-output 커맨드 제거 (#47)
Browse files Browse the repository at this point in the history
* chore: 테스트 트리거 활성화

* chore: set-output 대신 github env를 사용하도록 개선

* chore: 환경변수 이름 변경

* chore: 테스트 명령어 추가

* chore: 환경변수 출력 테스트

* chore: 환경변수를 전역 컨텍스트로 선언

* chore: 전역 환경변수가 미리 평가되도록 변경

* chore: 환경변수를 잡의 아웃풋으로 전달하도록 수정

* fix: 신택스 오류 수정

* fix: 같은 잡 내에서는 스텝 아웃풋 사용하도록 수정

* chore: NCP 유저네임 시크릿 처리

* chore: 테스트 스크립트 제거

* chore: 테스트 트리거 롤백

* chore: NCP 유저네임 시크릿 처리
  • Loading branch information
uwoobeat authored Dec 7, 2023
1 parent 4f1c2bb commit 16ee5f6
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/develop_build_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ jobs:
java-version: [ 17 ]
distribution: [ 'temurin' ]
outputs:
sha: ${{ steps.github-sha-short.outputs.sha }}
# IMAGE_TAG 환경 변수를 다른 Job에서 사용하기 위해 설정
image-tag: ${{ steps.image-tag.outputs.value }}
steps:
# 기본 체크아웃
- name: Checkout
Expand All @@ -26,10 +27,10 @@ jobs:
java-version: ${{ matrix.java-version }}
distribution: ${{ matrix.distribution }}

# GITHUB SHA Short
- name: GitHub SHA Short
id: github-sha-short
run: echo "::set-output name=sha::$(echo ${GITHUB_SHA} | cut -c1-7)"
# 이미지 태그 설정
- name: Set up image-tag by GITHUB_SHA
id: image-tag
run: echo "value=$(echo ${GITHUB_SHA::7})" >> $GITHUB_OUTPUT

# Gradlew 실행 허용
- name: Run chmod to make gradlew executable
Expand Down Expand Up @@ -59,14 +60,14 @@ jobs:
with:
context: .
push: true
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ steps.github-sha-short.outputs.sha }}
tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ steps.image-tag.outputs.value }}

# 서버로 docker-compose 파일 전송
- name: Copy docker-compose.yml to NCP Server
uses: appleboy/scp-action@v0.1.4
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
username: ${{ secrets.NCP_USERNAME }}
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
source: docker-compose.yaml
Expand All @@ -92,15 +93,15 @@ jobs:
uses: appleboy/ssh-action@master
env:
NCP_CONTAINER_REGISTRY: ${{ secrets.NCP_CONTAINER_REGISTRY }}
NCP_IMAGE_TAG: ${{ needs.build.outputs.sha }}
NCP_IMAGE_TAG: ${{ needs.build.outputs.image-tag }}
with:
host: ${{ secrets.NCP_HOST }}
username: tenminute
username: ${{ secrets.NCP_USERNAME }}
key: ${{ secrets.NCP_PRIVATE_KEY }}
port: ${{ secrets.NCP_PORT }}
envs: NCP_CONTAINER_REGISTRY,NCP_IMAGE_TAG # docker-compose.yml 에서 사용할 환경 변수
script: |
echo "${{ secrets.NCP_SECRET_KEY }}" | docker login -u "${{ secrets.NCP_ACCESS_KEY }}" --password-stdin "${{ secrets.NCP_CONTAINER_REGISTRY }}"
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ needs.build.outputs.sha }}
docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server-spring:${{ env.NCP_IMAGE_TAG }}
docker compose -f /home/tenminute/docker-compose.yaml up -d
docker image prune -a -f

0 comments on commit 16ee5f6

Please sign in to comment.