我從未在 github 操作中撰寫管道,我被要求為拉取請求創建管道,我做了一些事情:
# This is a basic workflow to help you get started with Actions
name: pipeline_action_on_pull_request
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
pull_request:
branches:
- dev
# 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"
lint_and_test:
# The type of runner that the job will run on
runs-on: linux
# 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
- uses: actions/setup-node@v2
with:
node-version: '16'
- run: npm install
- run: npm lint
- run: npm test
但是在 pull reqeust 之后它的輸出是:
No runner matching the specified labels was found: linux
uj5u.com熱心網友回復:
我準備了一個 esquema 來部署到生產環境,你需要使用 npm install、Clean .cache、Build Development 等,如下所示:
jobs:
build:
if: contains(github.ref, 'development') || contains(github.ref, 'production')
name: Build
runs-on: ubuntu-latest
steps:
- name: node version
run: node -v
- run: echo ${{ github.ref }}
- name: Checkout Repo
uses: actions/checkout@v2
- name: Install dependencies
run: npm install
- name: Build Development
if: contains(github.ref, 'development')
run: npm run build
通過檔案https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idruns-on
GitHub 托管的運行器 如果您使用 GitHub 托管的運行器,則每個作業都會在由 run-on 指定的虛擬環境的新實體中運行。
可用的 GitHub 托管的運行器型別有:
虛擬環境 YAML 作業流標簽注釋 Windows Server 2022[beta] windows-2022 windows-latest 標簽當前使用 Windows Server 2019 運行器映像。Windows Server 2019 windows-latest 或 windows-2019 Windows Server 2016[deprecated] windows-2016 遷移到 Windows 2019 或 Windows 2022。有關詳細資訊,請參閱博客文章。Ubuntu 20.04 ubuntu-latest 或 ubuntu-20.04 Ubuntu 18.04 ubuntu-18.04 macOS Big Sur 11 macos-11 macos-latest 標簽目前使用 macOS 10.15 runner 鏡像。macOS Catalina 10.15 macos-latest 或 macos-10.15
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/354746.html
標籤:github 新产品经理 github-actions 拉取请求 npm 运行
