-
Notifications
You must be signed in to change notification settings - Fork 33
92 lines (89 loc) · 3.27 KB
/
gitlab_ci.yml
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
name: Mirror to Gitlab to trigger CI
on:
push:
pull_request_target:
schedule:
- cron: '1 5 2 * *'
jobs:
check_permission:
runs-on: ubuntu-latest
if: >-
(github.repository_owner == 'Parallel-in-Time') &&
((github.event_name == 'push') ||
(github.event_name == 'schedule') ||
((github.event_name == 'pull_request_target') &&
(contains(github.event.pull_request.labels.*.name, 'gitlab-mirror'))
)
)
steps:
- name: Query permissions of triggering actor
id: query_permission_triggering_actor
if: github.event_name == 'pull_request_target'
uses: actions-cool/check-user-permission@v2
with:
username: ${{ github.triggering_actor }}
require: 'write'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Interpret the queried result
if: github.event_name == 'pull_request_target'
run: |
echo "Current permission level is ${{ steps.query_permission_triggering_actor.outputs.user-permission }}"
echo "Job originally triggered by ${{ github.actor }}"
echo "Checking permission returned ${{ steps.query_permission_triggering_actor.outputs.require-result }}"
if ${{ steps.query_permission_triggering_actor.outputs.require-result }}
then
echo 'Permissions granted'
exit 0
else
echo 'Not enough permissions'
exit 1
fi
- name: Pass if workflow from push or schedule
if: >-
(github.event_name == 'push') ||
(github.event_name == 'schedule')
run: exit 0
# - name: Fail for other triggers
# if: >-
# (github.event_name != 'push') &&
# (github.event_name != 'schedule') &&
# (github.event_name != 'pull_request_target')
# run: exit 1
mirror_to_gitlab:
runs-on: ubuntu-latest
if: >-
(github.repository_owner == 'Parallel-in-Time') &&
((github.event_name == 'push') ||
(github.event_name == 'schedule') ||
((github.event_name == 'pull_request_target') &&
(contains(github.event.pull_request.labels.*.name, 'gitlab-mirror'))
)
)
needs:
- check_permission
steps:
- name: set proper sha
run: |
echo "${{ github.event_name }}"
if [ "${{ github.event_name }}" == 'push' ] || [ "${{ github.event_name }}" == 'schedule' ]
then
echo "USED_SHA=${{ github.sha }}" >> "$GITHUB_ENV"
fi
if [ "${{ github.event_name }}" == 'pull_request_target' ]
then
echo "USED_SHA=${{ github.event.pull_request.head.sha }}" >> "$GITHUB_ENV"
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: "${{ env.USED_SHA }}"
persist-credentials: false
- name: Mirror and wait for Gitlab-CI
uses: jakob-fritz/github2lab_action@Iss35_mirror_pr
env:
MODE: 'all' # Either 'mirror', 'get_status', 'get_artifact', or 'all'
GITLAB_TOKEN: ${{ secrets.GITLAB_SECRET }}
FORCE_PUSH: "true"
GITLAB_HOSTNAME: "gitlab.jsc.fz-juelich.de"
GITLAB_PROJECT_ID: "6029"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}