合并请求合并后,我想触发我的GitHub ci 。因为在合并请求合并到 GitHub
后,我想将源从 GitHub 运送到 gitlab示例 -https://github.com/kumaresan-subramani/ej2-blaz-doc/pull/7
创建拉取请求后立即触发CI,但是合并后不会触发CI,因此我无法将我的源代码从github运送到gitlab
我的yml文件:
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
types: [opened, closed]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: set environment variables
uses: allenevans/set-env@v1.0.0
with:
MY_ENV_VAR: 'my value'
GIT_USER: ${{ secrets.USER }}
GIT_TOKEN: ${{ secrets.TOKEN }}
- name: Install
run: npm i
- name: Publish
run: npm run publish
if: github.event.pull_request.merged == 'true'
答案 0 :(得分:0)
您需要将字段值merged
与布尔值(而不是字符串)进行比较。
github.event.pull_request.merged == true
代替github.event.pull_request.merged == 'true'
您也可以写:
if: github.event.pull_request.merged
例如,以下工作流程在打开/关闭PR时比较值:
on:
pull_request:
types: [opened, closed]
name: build
jobs:
build:
name: Input check
runs-on: ubuntu-latest
steps:
- name: Checking your input
run: |
echo "github.event.pull_request.merged : $MERGED_RAW"
echo "github.event.pull_request.merged == 'true' : $MERGED_TRUE_STR"
echo "github.event.pull_request.merged == true : $MERGED_TRUE_BOOL"
env:
MERGED_RAW: ${{ github.event.pull_request.merged }}
MERGED_TRUE_STR: ${{ github.event.pull_request.merged == 'true' }}
MERGED_TRUE_BOOL: ${{ github.event.pull_request.merged == true }}
合并PR时,会得到以下结果:
github.event.pull_request.merged : true
github.event.pull_request.merged == 'true' : false
github.event.pull_request.merged == true : true