-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (46 loc) · 1.81 KB
/
Copy pathtrigger.yaml
File metadata and controls
50 lines (46 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
name: trigger
on:
workflow_call:
secrets:
GH_TOKEN:
required: true
GITLAB_PROJECT_ID:
required: true
GITLAB_TRIGGER_TOKEN:
required: true
inputs:
PROJECT:
required: false
type: string
COMMIT_MESSAGE:
required: false
type: string
GH_REPOSITORY:
required: false
type: string
jobs:
trigger:
runs-on: ubuntu-latest
steps:
- name: Trigger GitLab pipeline
run: |
REPO_NAME="${GITHUB_REPOSITORY##*/}"
if [ -n "${{ inputs.PROJECT }}" ]; then
REPO_NAME="${{ inputs.PROJECT }}"
fi
CURL_CMD=(
curl --request POST "https://gitlab.com/api/v4/projects/${GITLAB_PROJECT_ID}/trigger/pipeline"
--form token="${GITLAB_TRIGGER_TOKEN}"
--form ref="${{ github.ref_name }}"
--form "variables[REPOSITORY]=${{ inputs.GH_REPOSITORY }}"
--form "variables[PROJECT]=$REPO_NAME"
--form "variables[BRANCH]=${{ github.ref_name }}"
--form "variables[COMMIT_SHA]=${{ github.sha }}"
)
if [ -n "${{ inputs.COMMIT_MESSAGE }}" ]; then
CURL_CMD+=( --form "variables[COMMIT_MESSAGE]=${{ inputs.COMMIT_MESSAGE }}" )
fi
"${CURL_CMD[@]}"
env:
GITLAB_PROJECT_ID: ${{ secrets.GITLAB_PROJECT_ID }}
GITLAB_TRIGGER_TOKEN: ${{ secrets.GITLAB_TRIGGER_TOKEN }}