nextstarproject / tools-fe

Online pure front end tools by nextstarproject
https://tools.nextstar.space
GNU General Public License v3.0
0 stars 1 forks source link

自动化Action发布到netlify #6

Closed SpiritLing closed 1 year ago

SpiritLing commented 1 year ago

Github Actions deploy

AlbertXiaoPeng commented 1 year ago

cli: https://cli.netlify.com/commands/deploy

netlify deploy
netlify deploy --site my-first-site
netlify deploy --prod
netlify deploy --prod --open
netlify deploy --prodIfUnlocked
netlify deploy --message "A message with an $ENV_VAR"
netlify deploy --auth $NETLIFY_AUTH_TOKEN
netlify deploy --trigger
netlify deploy --build --context deploy-preview
AlbertXiaoPeng commented 1 year ago

使用 workflow_run 来进行判定,这种不知道为何不生效? https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run

name: Deploy prod

on:
  push:
    branches: [ "master" ]
  workflow_run:
    workflows: [ Node pnpm CI ]
    branches: [ "master" ]
    types:
      - completed

permissions:
  contents: read

jobs:
  on-success:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    steps:
      - uses: actions/checkout@v3
      - name: Use Node.js ${{ matrix.node_version }}
        uses: actions/setup-node@v3
        with:
          node-version: 16.x
        env:
          CI: true
          PROGRESS: none
          NODE_ENV: test
          NODE_OPTIONS: --max_old_space_size=4096
          NETLIFY_ACCESS_TOKEN: ${{ secrets.NETLIFY_ACCESS_TOKEN }}
          NETLIFY_PREVIEW_ID: ${{ secrets.PREVIEW_ID }}
          NETLIFY_PROD_ID: ${{ secrets.PROD_ID }}
      - run: echo ${{github.ref}}
      - run: npm install -g pnpm
      - run: pnpm config set store-dir ~/.pnpm-store
      - run: pnpm install --strict-peer-dependencies=false
      - run: pnpm add -g netlify-cli
      - run: pnpm run build
      - run: netlify deploy --site $NETLIFY_PROD_ID --dir dist --auth $NETLIFY_ACCESS_TOKEN --prod

  on-failure:
    runs-on: ubuntu-latest
    if: ${{ github.event.workflow_run.conclusion == 'failure' }}
    steps:
      - run: echo 'The node pnpm CI workflow failed'
AlbertXiaoPeng commented 1 year ago

使用 https://github.com/rhysd/actionlint 来进行actions的错误判定,防止多次无效提交 42abcd11f726761b8a16690f6c694e0d54da98bf...050dddeb6754924e5a5b9f631ed82083db2cb25d

Windows 可以使用 choco 安装

choco install actionlint