Skip to content

cicd

cicd #5

Workflow file for this run

name: Deploy Management Action
on:
push:
branches:
- release-test
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# 1) 소스 체크아웃
- uses: actions/checkout@v3
# 2) Node.js 세팅
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22'
registry-url: 'https://registry.npmjs.org/'
# 3) package.json 버전이 기존 태그와 다른지 확인
- name: Check if version has been updated
id: check-version
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
# 혹시 태그가 하나도 없을 경우 에러가 발생할 수 있으므로 || echo "v0.0.0" 추가
LAST_GIT_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
echo "현재 package.json 버전: v$PACKAGE_VERSION"
echo "가장 최근 태그: $LAST_GIT_TAG"
if [ "v$PACKAGE_VERSION" = "$LAST_GIT_TAG" ]; then
echo "Package version ($PACKAGE_VERSION) has not been updated since the last tag ($LAST_GIT_TAG)."
exit 1
else
echo "Package version has been updated to $PACKAGE_VERSION."
# GitHub Actions 최신 문법: $GITHUB_OUTPUT 파일에 기록
echo "package_version=$PACKAGE_VERSION" >> $GITHUB_OUTPUT
fi
# 4) 패키지 설치
- name: Install dependencies
run: npm ci
# 5) 빌드
- name: Build
run: npm run build
# 6) npm publish
- name: Deploy
run: npm publish --tag alpha
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} # NPM 토큰
# 7) 스크립트 실행 (마일스톤 관리 등 필요 작업)
- name: Execute script for milestone
run: node .github/scripts/manage-deploy.js ${{ steps.check-version.outputs.package_version }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}