📝 new commercial 【讲点黑话54】抛弃电视,都是自己作的 #21
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: | |
workflow_dispatch: | |
push: | |
branches: [ master ] | |
pull_request: | |
types: | |
- opened | |
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.DIFF }} | |
branch: ${{ steps.diff.outputs.branch }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.head_ref || github.ref }} | |
fetch-depth: 0 | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT | |
- name: get diff | |
id: diff | |
run: | | |
echo $(git diff --name-only HEAD origin/master -- docs) | |
echo $(git diff --name-only HEAD origin/master -- docs) | wc -w | xargs -I {} echo "DIFF={}" >> "$GITHUB_OUTPUT" | |
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 --build-env GIT_BRANCH=${{ needs.check-if-need-deploy.outputs.branch || 'master' }} --token=${{ secrets.VERCEL_TOKEN }} --target=${{ steps.get-deploy-env.outputs.TARGET_ENV }} |