【问题标题】:auto deploy GitHub repo using GitHub actions使用 GitHub 操作自动部署 GitHub 存储库
【发布时间】:2024-06-04 23:50:02
【问题描述】:

我在 Github Actions 中创建了一个动作,用于在 spray.sh 上部署 React App Repo。实际上,所有作业都已成功完成,但在浪涌时部署的作业将因出错而失败

"Run surge ./build http://reactapp-saim.surge.sh --token ***
   Running as innovativetech1990@gmail.com (Student)
   **Aborted - No such file or directory: ./build**
Error: Process completed with exit code 1."

我的工作代码是

    name: React app deploy

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the main branch
  push:
    branches: [ main ]


  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2

      # Runs a single command using the runners shell
      - name: installing node 
        uses: actions/setup-node@v2
        with: 
          node-version: '14'
          
      - name: GitHub Action for Yarn
        # You may pin to the exact commit or the version.
        # uses: Borales/actions-yarn@4965e1a0f0ae9c422a9a5748ebd1fb5e097d22b9
        uses: Borales/actions-yarn@v2.3.0
        with:
          # Yarn command
          cmd: install
          
      - name: creating build
        run: npm build # npm build
        
      - name: installing surge
        run: npm install -g surge
        
      - name: deploying with surge
        run: surge ./build http://reactapp-saim.surge.sh --token ${{ secrets.SURGE_TOKEN}}

【问题讨论】:

    标签: reactjs continuous-deployment


    【解决方案1】:

    此代码未正确生成捆绑包。

    - name: creating build
        run: npm build # npm build
    

    您需要运行 npm run buildnpm run-script build 所以你的步骤如下所示:

    - name: creating build
            run: npm run build
    

    【讨论】:

    • 按照您的指南完成,但现在使用 npm run build 出现此错误正在创建优化的生产构建...编译失败。 EACCES:权限被拒绝,mkdir '/home/runner/work/bootcamp-react-app/bootcamp-react-app/node_modules/.cache'
    • 当我在终端上运行此代码时,它可以正常工作,但在 Github 中操作会出错
    最近更新 更多