Home

Awesome

🚀 GitLab CI for GitHub Actions

trigger gitlab job

GitHub Action for trigger gitlab-ci jobs. See Trigger pipelines by using the API.

Usage

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/gitlab-ci-action@v1.3.0
      with:
        host: "http://example.com"
        token: ${{ secrets.TOKEN }}
        project_id: 100

GitLab Setting

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.

token

How to get the project ID? going to your project’s Settings ➔ General under General project.

projectID

Example

Specific the GitLab host URL:

- name: trigger Job
  uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
  with:
    host: "http://example.com"
    token: ${{ secrets.TOKEN }}
    debug: true
    project_id: 100

Other specific branch or tag name:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     ref: v1.0.0

Pass the variables to the triggered pipeline:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     variables: key1=value01,key2=value02

Wait for pipeline to complete, default as false:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     wait: true

Timeout waiting for pipeline to complete, default as 1h:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     wait: true
+     timeout: 60s

Interval waiting for pipeline to complete, default as 5s:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     wait: true
+     interval: 10s

Allow insecure SSL connections, default as false:

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
    with:
      host: "http://example.com"
      token: ${{ secrets.TOKEN }}
      debug: true
      project_id: 100
+     insecure: true

Show output status

  - name: trigger Job
    uses: ghcr.io/appleboy/gitlab-ci-action@v1.3.0
+   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 }}

Input variables

Output variables