📝 new btnews 【睡前消息861】永州苯泄露,回避问题不算最差选择 (#102) #75
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: get diff | |
id: diff | |
run: | | |
echo $(git diff --name-only HEAD origin/master -- docs) | |
echo $(git diff --name-only HEAD HEAD^ -- docs) | |
if [[ ${{ github.event_name }} == 'pull_request' ]]; then | |
echo $(git diff --name-only HEAD origin/master -- docs) | wc -w | xargs -I {} echo "DIFF={}" >> "$GITHUB_OUTPUT" | |
else | |
echo $(git diff --name-only HEAD HEAD^ -- docs) | wc -w | xargs -I {} echo "DIFF={}" >> "$GITHUB_OUTPUT" | |
fi | |
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: add env | |
# run: echo "GIT_BRANCH=${{ github.head_ref || 'master' }}" >> .vercel/.env.${{ steps.get-deploy-env.outputs.TARGET_ENV }}.local | |
# - 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=${{ github.head_ref || 'master' }} --token=${{ secrets.VERCEL_TOKEN }} --target=${{ steps.get-deploy-env.outputs.TARGET_ENV }} |