在多个环境中运行GitHub Action [英] Run GitHub Action on multiple environments
本文介绍了在多个环境中运行GitHub Action的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当前,我要做的是在多个环境(例如在Windows和Linux上)上运行GitHub Actions.我设法通过Travis CI做到了这一点,但是找不到有关如何使用GitHub Actions做到这一点的信息.
Currently what I want to do is to run the GitHub Actions on more than one environment, let's say on windows and linux. I managed to do it with the Travis CI, but I could not find information about how to do it with GitHub Actions.
有人尝试过吗?
当前,这是我的nodejs.yml.
Currently, this is my nodejs.yml.
name: Node CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
npm ci
- name: prettier format check
run: |
npm run prettier-check
- name: lint format check
run: |
npm run lint-check
- name: build, and test
run: |
npm run build
npm test --if-present
env:
CI: true
推荐答案
You can use a strategy / matrix for that (see https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idstrategy)
name: Node CI
on: [push]
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: npm install
run: |
npm ci
- name: prettier format check
run: |
npm run prettier-check
- name: lint format check
run: |
npm run lint-check
- name: build, and test
run: |
npm run build
npm test --if-present
env:
CI: true
这篇关于在多个环境中运行GitHub Action的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文