我试图使用以下条件启动Github操作工作流作业,每个条件启动一个单独的作业:
如果有一个新的拉请求将开发分支部署基础设施部署到dev环境
< code >g29。
on:
push:
branches:
- dev
- main
pull_request:
types: [opened, reopened]
branches:
- dev
- main
workflow_dispatch:
jobs:
DeployDev:
name: Deploy to dev
if: ${{github.ref == 'refs/heads/dev' && github.event_name == 'pull_request'}}
runs-on: ubuntu-latest
environment: dev
more steps follows ......类似地,对于其他匹配条件(要运行的单独作业),我将使用
DeployUat:
if: ${{github.ref == 'refs/heads/dev' && github.event_name == 'push'}}DeployStaging:
if: ${{github.ref == 'refs/heads/main' && github.event_name == 'pull_request'}}DeployProd:
${{github.ref == 'refs/heads/main' && github.event_name == 'push'}}当代码合并时,工作流作业似乎运行正常,但在创建拉请求时则不运行。
有人能指出我做错了什么吗?我试着删除行types: [opened, reopened],但没有产生任何区别。
发布于 2022-06-02 05:58:21
我想我找到了答案。
而不是if: $github.ref == 'refs/heads/dev' && github.event_name == 'pull_request'
应该是if: $github.event.pull_request.base.ref == 'dev' && github.event_name == 'pull_request'
https://stackoverflow.com/questions/72420871
复制相似问题