我有一个GA工作流程来部署我的React应用here。它在由三个独立的NodeJS版本组成的矩阵上运行签出/安装/构建/测试步骤,然后运行部署。我担心的是,根据矩阵,这将尝试运行部署三次,这可能会导致问题。有没有好的方法来过滤最后一步,让它只运行一次?
我目前最好的猜测是将30-32行更改为下面的行,但我不确定它是否能正确工作。
- name: Deploy
if: matrix.node-version == '10.x' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')
run: | ...发布于 2021-02-05 03:52:49
添加一个仅在1个节点版本上运行的单独部署作业,并对上一个矩阵作业(包含needs /install/Test.)进行测试以使其成功。我还将您的第一个工作重命名为test,因为这更准确地描述了它所做的事情。
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build --if-present
- run: npm test
deploy:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v2
# might need build steps here, I'm not 100% certain on your npm config
- name: Deploy
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
run: |
git config --global user.name $user_name
git config --global user.email $user_email
git remote set-url origin https://${github_token}@github.com/${repository}
npm run deploy
env:
user_name: "github-actions[bot]"
user_email: "github-actions[bot]@users.noreply.github.com"
github_token: ${{ secrets.ACTIONS_DEPLOY_ACCESS_TOKEN }}
repository: ${{ github.repository }}https://stackoverflow.com/questions/66052643
复制相似问题