fix: AppBanner target blank 추가 #1984
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | |
on: | |
push: | |
branches-ignore: | |
- "**" | |
tags: | |
- "release-prod-*" | |
- "release-pr-*" | |
env: | |
GITHUB_API_URL_BASE: https://api.github.com/repos/${{ github.repository }} | |
# Node.js | |
NODE_VERSION: "lts/*" | |
NPM_REGISTRY_URL: "https://registry.npmjs.org" | |
NODE_AUTH_TOKEN: ${{ secrets.READ_ONLY_NPM_TOKEN }} | |
HUSKY: 0 | |
# Slack notifications | |
SLACK_WEBHOOK: ${{ secrets.GHA_NOTIFICATIONS_WEBHOOK_URL }} | |
SLACK_CHANNEL: "#triple-web-dev-notifications" # 메시지 보낼 채널 | |
SLACK_USERNAME: "Triple Frontend" # 메시지를 보내는 계정 이름 | |
SLACK_ICON_EMOJI: ":triple_new:" | |
SLACK_DETAIL_URL: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
SLACK_GITHUB_REPOSITORY: ${{ github.repository }} | |
SLACK_AUTHOR_NAME: ${{ github.event.sender.login }} | |
SLACK_AUTHOR_ICON: ${{ github.event.sender.avatar_url }} | |
SLACK_FOOTER: ${{ github.repository }} | |
SLACK_GITHUB_REF: ${{ github.event.ref }} # 메시지에 ref로 표시되는 값 | |
SLACK_GITHUB_EVENT_NAME: ${{ github.event_name }} # 메시지에 Event로 표시되는 값 | |
# Nx Cloud | |
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }} | |
jobs: | |
wait-for-ci: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: ${{ env.NPM_REGISTRY_URL }} | |
- name: Wait for CI | |
uses: fountainhead/action-wait-for-check@v1.1.0 | |
id: wait-for-ci | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
checkName: build | |
- name: Notify checking CI timeout | |
if: steps.wait-for-ci.outputs.conclusion == 'timed_out' | |
env: | |
SLACK_COLOR: fail | |
SLACK_TITLE: ":pleading: CI Waiting timeout" | |
SLACK_TOPIC: "CI workflow가 시작되었는지, 기다리는 job의 이름이 CI job과 일치하는지, 확인해주세요." | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Notify checking CI failure | |
if: steps.wait-for-ci.outputs.conclusion == 'failure' | |
env: | |
SLACK_COLOR: fail | |
SLACK_TITLE: ":pleading: CI FAILURE" | |
SLACK_TOPIC: "배포를 중단합니다." | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Shutdown workflow | |
if: steps.wait-for-ci.outputs.conclusion != 'success' | |
run: node -e 'process.exit(1)' | |
release: | |
needs: wait-for-ci | |
if: startsWith(github.event.ref, 'refs/tags/release-prod-') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: ${{ env.NPM_REGISTRY_URL }} | |
- name: Get release version | |
run: echo "DEPLOY_VERSION=v$(cat ./lerna.json | jq -r '.version')" >> $GITHUB_ENV | |
- name: Notify deploy start to slack | |
env: | |
SLACK_COLOR: gray | |
SLACK_TITLE: ":rocket: Release WORKING" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Install dependencies | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READ_ONLY_NPM_TOKEN }} | |
run: pnpm install | |
- run: pnpm run build | |
- name: Release | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READ_WRITE_NPM_TOKEN }} | |
run: pnpm -r publish --no-git-checks | |
- name: Notify deploy success to slack | |
if: success() | |
env: | |
SLACK_COLOR: success | |
SLACK_TITLE: ":tada: Release SUCCESS" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Notify deploy fail to slack | |
if: failure() | |
env: | |
SLACK_COLOR: fail | |
SLACK_TITLE: ":pleading: Release FAILURE" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify | |
tag: | |
needs: release | |
if: success() | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get released version | |
run: echo "TAG_NAME=v$(cat ./lerna.json | jq -r '.version')" >> $GITHUB_ENV | |
- name: Create tag object | |
id: create-tag-object | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-tag-object | |
run: | | |
curl --url $GITHUB_API_URL_BASE/git/tags \ | |
-f \ | |
--request POST \ | |
-H 'Authorization: token ${{ secrets.TRIPLE_BOT_GITHUB_TOKEN }}' \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"tag\":\"$TAG_NAME\",\"message\":\"released at \`${{ github.event.updated_at }}\`\",\"object\":\"${GITHUB_SHA}\",\"type\":\"commit\"}" \ | |
> tag.json | |
echo "::set-output name=tag-sha::$(node -p -e 'require(`./tag.json`).sha')" | |
- name: Check tag ref exist | |
id: check-tag-ref | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/git#get-a-reference | |
run: | | |
curl --url $GITHUB_API_URL_BASE/git/refs/tags/$TAG_NAME \ | |
-sI \ | |
-o /dev/null \ | |
-w "%{http_code}" \ | |
-H 'Authorization: token ${{ secrets.TRIPLE_BOT_GITHUB_TOKEN }}' \ | |
> status | |
echo "::set-output name=status::$(cat status)" | |
- name: Create new tag ref | |
if: ${{ steps.check-tag-ref.outputs.status != '200' }} | |
env: | |
TAG_SHA: ${{ steps.create-tag-object.outputs.tag-sha }} | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/git#create-a-reference | |
run: | | |
curl --url $GITHUB_API_URL_BASE/git/refs \ | |
-f \ | |
--request POST \ | |
-H 'Authorization: token ${{ secrets.TRIPLE_BOT_GITHUB_TOKEN }}' \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"ref\":\"refs/tags/$TAG_NAME\",\"sha\":\"$TAG_SHA\"}" | |
- name: Update tag ref | |
if: ${{ steps.check-tag-ref.outputs.status == '200' }} | |
env: | |
TAG_SHA: ${{ steps.create-tag-object.outputs.tag-sha }} | |
# https://docs.github.com/en/free-pro-team@latest/rest/reference/git#update-a-reference | |
run: | | |
curl --url $GITHUB_API_URL_BASE/git/refs/tags/$TAG_NAME \ | |
-f \ | |
--request PATCH \ | |
-H 'Authorization: token ${{ secrets.TRIPLE_BOT_GITHUB_TOKEN }}' \ | |
-H 'Content-Type: application/json' \ | |
-d "{\"force\":true,\"sha\":\"${TAG_SHA}\"}" | |
canary-release: | |
needs: wait-for-ci | |
if: startsWith(github.event.ref, 'refs/tags/release-pr-') | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: pnpm/action-setup@v2 | |
with: | |
version: 8 | |
- name: Use Node.js ${{ env.NODE_VERSION }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ env.NODE_VERSION }} | |
registry-url: ${{ env.NPM_REGISTRY_URL }} | |
- name: Get release version | |
env: | |
TAG_NAME: ${{ github.event.ref }} | |
run: | | |
NEXT_VERSION=$(node -e "const [major, minor, patch] = require('./lerna.json').version.split('.');console.log(['v'+major, minor, parseInt(patch, 10) + 1].join('.'))") | |
PR_NUMBER=${TAG_NAME:21} # refs/tags/release-pr-<num>에서 <num>만 추출 | |
REF_COUNT=$(node -p -e "Math.max(0, parseInt((\"$(git describe --always --long --dirty --match "v*.*.*")\".match(/^(?:.*@)?.*-(\d+)-.*?$/) || ['0', '0'])[1], 10) - 1)") | |
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_ENV | |
echo "DEPLOY_VERSION=$NEXT_VERSION-pr-$PR_NUMBER.$REF_COUNT" >> $GITHUB_ENV | |
- name: Notify release start to Slack | |
env: | |
SLACK_COLOR: gray | |
SLACK_TITLE: ":rocket: Release WORKING" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Install dependencies | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READ_ONLY_NPM_TOKEN }} | |
run: pnpm install | |
- run: pnpm run build | |
- run: | | |
pnpm exec lerna version $DEPLOY_VERSION \ | |
--amend \ | |
--force-publish \ | |
--ignore-scripts \ | |
--no-git-tag-version \ | |
--preid "pr-$PR_NUMBER" \ | |
--yes | |
- name: Publish as canary | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.READ_WRITE_NPM_TOKEN }} | |
run: pnpm -r publish --tag canary --no-git-checks | |
- name: Notify released version on pull request | |
run: | | |
curl \ | |
--url $GITHUB_API_URL_BASE/issues/${{ env.PR_NUMBER }}/comments \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-f --request POST \ | |
-d "{\"body\":\"${{ env.DEPLOY_VERSION }} has been published!\"}" | |
- name: Notify release success to Slack | |
if: success() | |
env: | |
SLACK_COLOR: success | |
SLACK_TITLE: ":tada: Release SUCCESS" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify | |
- name: Notify release failure to Slack | |
if: failure() | |
env: | |
SLACK_COLOR: fail | |
SLACK_TITLE: ":pleading: Release FAILURE" | |
SLACK_TOPIC: ${{ env.DEPLOY_VERSION }} | |
run: pnpm dlx @titicaca/gha-tools notify |