Skip to content

Commit

Permalink
First version of CI to mirror pull_requests to Gitlab
Browse files Browse the repository at this point in the history
If someone with write-permissions triggered the workflow
  • Loading branch information
jakob-fritz committed Jan 8, 2024
1 parent 9bd2c2c commit 5a5de4a
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 34 deletions.
34 changes: 0 additions & 34 deletions .github/workflows/ci_pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,6 @@ jobs:
run: |
flakeheaven lint --benchmark pySDC
# mirror_to_gitlab:

# runs-on: ubuntu-latest

# steps:
# - name: Checkout
# uses: actions/checkout@v1

# - name: Mirror
# uses: jakob-fritz/github2lab_action@main
# env:
# MODE: 'mirror' # Either 'mirror', 'get_status', or 'both'
# GITLAB_TOKEN: ${{ secrets.GITLAB_SECRET_H }}
# FORCE_PUSH: "true"
# GITLAB_HOSTNAME: "codebase.helmholtz.cloud"
# GITLAB_PROJECT_ID: "3525"
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

user_cpu_tests_linux:
runs-on: ubuntu-latest

Expand Down Expand Up @@ -170,22 +152,6 @@ jobs:
# pytest --continue-on-collection-errors -v --durations=0 pySDC/tests -m ${{ matrix.env }}


# wait_for_gitlab:
# runs-on: ubuntu-latest

# needs:
# - mirror_to_gitlab

# steps:
# - name: Wait
# uses: jakob-fritz/github2lab_action@main
# env:
# MODE: 'get_status' # Either 'mirror', 'get_status', or 'both'
# GITLAB_TOKEN: ${{ secrets.GITLAB_SECRET_H }}
# FORCE_PUSH: "true"
# GITLAB_HOSTNAME: "codebase.helmholtz.cloud"
# GITLAB_PROJECT_ID: "3525"
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# # - name: Get and prepare artifacts
# # run: |
Expand Down
57 changes: 57 additions & 0 deletions .github/workflows/gitlab_ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
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'
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
- name: Interpret the queried result
if: github.event_name == 'pull_request_target'
run: |
echo $steps.query_permission_triggering_actor.outputs.require-result
return !steps.query_permission_triggering_actor.outputs.require-result
- name: Pass if workflow from push or schedule
if: >-
(github.event_name == 'push') ||
(github.event_name == 'schedule')
run: return 0
- name: Fail for other triggers
if: >-
(github.event_name != 'push') &&
(github.event_name != 'schedule') &&
(github.event_name != 'pull_request_target')
run: return 1

mirror_to_gitlab:
runs-on: ubuntu-latest
if: ${{ github.repository_owner == 'Parallel-in-Time'}}
needs:
- check_permission
steps:
- name: Checkout
uses: actions/checkout@v1
with:
ref: ${{ github.event.pull_request.head.sha }}
- 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 }}

0 comments on commit 5a5de4a

Please sign in to comment.