📝 new commercial 【讲点黑话61】弱小不是生存的障碍 傲慢才是 #5
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: Deploy to Vercel | |
on: | |
push: | |
branches: [ master ] | |
pull_request_target: | |
branches: [ master ] | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
jobs: | |
check-if-need-deploy: | |
runs-on: ubuntu-latest | |
outputs: | |
doc-changed: ${{ steps.diff.outputs.count }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'master' | |
- uses: technote-space/get-diff-action@v6 | |
id: diff | |
with: | |
PATTERNS: | | |
docs/**/*.md | |
SET_ENV_NAME_COUNT: DIFF_COUNT | |
- name: show diff result | |
run: | |
echo ${{ env.GIT_DIFF }} | |
echo ${{ env.DIFF_COUNT }} | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
needs: [ check-if-need-deploy ] | |
if: ${{ needs.check-if-need-deploy.outputs.doc-changed != '0' }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: 'vitepress' | |
- uses: actions/setup-node@v4 | |
- name: install deps | |
run: npm install | |
- name: Install Vercel CLI | |
run: npm install --global vercel@latest | |
- name: Determine Deployment Environment | |
id: get-deploy-env | |
run: | | |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then | |
echo "TARGET_ENV=preview" >> $GITHUB_OUTPUT | |
else | |
echo "TARGET_ENV=production" >> $GITHUB_OUTPUT | |
fi | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=${{ steps.get-deploy-env.outputs.TARGET_ENV }} --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: vercel build --target=${{ steps.get-deploy-env.outputs.TARGET_ENV }} --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Deploy Project Artifacts to Vercel | |
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} --target=${{ steps.get-deploy-env.outputs.TARGET_ENV }} |