Adding the functionality #44
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Gitlab Pipeline Integration | |
on: | |
push: | |
workflow_dispatch: | |
jobs: | |
Gitlab_Trigger_Pipeline: | |
runs-on: cern:gitlab-ci | |
container: ghcr.io/miguensone/github-gitlab-sync:latest | |
env: | |
GITLAB_URL: ${{ vars.GITLAB_URL }} | |
PROJECT_ID: ${{ vars.PROJECT_ID }} | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
COMMIT_REF: ${{ github.sha }} | |
outputs: | |
job_matrix: ${{ steps.set-matrix.outputs.job_matrix }} | |
pipeline_id: ${{ steps.set-matrix.outputs.pipeline_id }} | |
steps: | |
- name: Trigger Gitlab Pipeline | |
id: set-matrix | |
run: | | |
python /opt/bridge/sync-repository.py | |
python /opt/bridge/create-temp-branch.py | |
export PIPELINE_ID=$(python /opt/bridge/trigger-pipeline.py) | |
export LIST_JOBS=$(python /opt/bridge/retrieve-jobs.py) | |
job_matrix=$(echo $LIST_JOBS | tr ',' '\n' | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "pipeline_id=${PIPELINE_ID}" >> $GITHUB_OUTPUT | |
echo "job_matrix=$job_matrix" >> $GITHUB_OUTPUT | |
echo Pipeline number: $PIPELINE_ID | |
echo Jobs detected: $job_matrix | |
Job: | |
needs: Gitlab_Trigger_Pipeline | |
runs-on: cern:gitlab-ci | |
container: ghcr.io/miguensone/github-gitlab-sync:latest | |
env: | |
GITLAB_URL: ${{ vars.GITLAB_URL }} | |
PROJECT_ID: ${{ vars.PROJECT_ID }} | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
strategy: | |
matrix: | |
run_id: ${{ fromJson(needs.Gitlab_Trigger_Pipeline.outputs.job_matrix) }} | |
fail-fast: false | |
steps: | |
- name: ${{ matrix.run_id }} | |
run: | | |
export JOB_ID=$(echo "${{ matrix.run_id }}" | awk -F'#' '{print $2}') | |
python /opt/bridge/retrieve-job.py | |
Gitlab_Pipeline_Final_Status: | |
needs: [Job, Gitlab_Trigger_Pipeline] | |
if: always() | |
runs-on: cern:gitlab-ci | |
container: ghcr.io/miguensone/github-gitlab-sync:latest | |
env: | |
GITLAB_URL: ${{ vars.GITLAB_URL }} | |
PROJECT_ID: ${{ vars.PROJECT_ID }} | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
PIPELINE_ID: ${{ needs.Gitlab_Trigger_Pipeline.outputs.pipeline_id }} | |
COMMIT_REF: ${{ github.sha }} | |
steps: | |
- name: Final Gitlab Pipeline Status | |
run: | | |
python /opt/bridge/wait-end-pipeline.py | |
python /opt/bridge/delete-temp-branch.py | |
python /opt/bridge/status-end-pipeline.py |