GitHub Action for trigger gitlab-ci jobs. See Trigger pipelines by using the API.
Trigger New GitLab CI Job.
name: trigger gitlab job
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
project_id: 100
See the detail documentation for Triggering pipelines through the API. Create your access token by going to your User Settings ➔ Access Tokens under Access Tokens.
How to get the project ID? going to your project’s Settings ➔ General under General project.
Specific the GitLab host URL:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100Other specific branch or tag name:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ ref: v1.0.0Pass the variables to the triggered pipeline:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ variables: key1=value01,key2=value02Wait for pipeline to complete, default as false:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ wait: trueTimeout waiting for pipeline to complete, default as 1h:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ wait: true
+ timeout: 60sInterval waiting for pipeline to complete, default as 5s:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ wait: true
+ interval: 10sAllow insecure SSL connections, default as false:
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ insecure: trueShow output status
- name: trigger Job
uses: ghcr.io/appleboy/[email protected]
+ id: trigger
with:
host: "http://example.com"
token: ${{ secrets.TOKEN }}
debug: true
project_id: 100
+ wait: true
+ interval: 1s
- name: print output
run: |
echo ${{ steps.trigger.outputs.id }}
echo ${{ steps.trigger.outputs.sha }}
echo ${{ steps.trigger.outputs.web_url }}
echo ${{ steps.trigger.outputs.status }}- host - Optional. gitlab-ci base url, default as
https://gitlab.com - token - Required. A unique trigger token can be obtained when adding a new trigger.
- project_id - Required. project id.
- ref - Optional. Triggers can be used to force a pipeline rerun of a specific ref (
branchortag) with an API call. Default asmain. - insecure - Optional. Allow insecure SSL connections. Default as
false. - variables - Optional. Variables to be passed to the triggered pipeline. Default as empty. example:
key1=value01,key2=value02. - debug - Optional. show the debug message.
- wait - Optional. wait for pipeline to complete. Default as
false. - timeout - Optional. timeout waiting for pipeline to complete. Default as
1h. - interval - Optional. interval waiting for pipeline to complete. Default as
5s.
- id - The ID of the triggered pipeline.
- sha - The sha of the triggered pipeline.
- web_url - The web URL of the triggered pipeline.
- status - The status of the triggered pipeline. (
running,pending,success,failed,canceled,skipped,manual,scheduled)

