Skip to content

GitHub

  • Action 发布 releases
yml
on:
  push:
    tags:
      - 'v*.*.*'

permissions:
  contents: write

- uses: softprops/action-gh-release@v2
  env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  with:
    files: dist/*
  • Action 发布 gh-page
yml
permissions:
  pages: write
  id-token: write

environment:
  name: github-pages
  url: ${{ steps.deployment.outputs.page_url }}

- uses: actions/upload-pages-artifact@v3
  with:
    path: '.'

- id: deployment
  uses: actions/deploy-pages@v4
  • 删除 deployments 记录

把部署标记为“非活动状态”

sh
REPO="user/repo"
for ID in $(gh api --method GET "/repos/$REPO/deployments?per_page=100" | jq -r ".[] | .id")
do
    gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" --method POST /repos/$REPO/deployments/$ID/statuses -f "state=inactive"
    gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" --method DELETE /repos/$REPO/deployments/$ID
done