Github 每一个新的提交动作——工作流反应 js 构建
Posted
技术标签:
【中文标题】Github 每一个新的提交动作——工作流反应 js 构建【英文标题】:Github every new commit actions-workflow react js build 【发布时间】:2021-12-18 14:01:16 【问题描述】:我在react js
中有一个Github
项目,其中有一个github-pages
页面。
每当我对项目进行更改时,在推送之前,我都会运行yarn build
命令为github-pages
创建内容,然后推送。
我想做的是每次在项目中进行新的提交时,都会随后执行构建。 无需我手动操作。
原因是如果我直接在浏览器上对github
项目进行修改,我无法构建该项目,因为我没有下载的项目及其npm modules
。
我想知道有没有可能做这样的事情?
package.json
"build": "npm run watch:css && react-scripts build && cp -R ./copy-build/. ./build && rm -rf docs && mv build docs"
【问题讨论】:
【参考方案1】:解决方案:
# This is a basic workflow to help you get started with Actions
name: Build
# 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
- name: Install Yarn
run: yarn
- name: Build
run: yarn build
【讨论】:
以上是关于Github 每一个新的提交动作——工作流反应 js 构建的主要内容,如果未能解决你的问题,请参考以下文章