diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d4ac42d65..98e0129ea 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -136,3 +136,17 @@ jobs: - name: Run rpmlint run: rpmlint rpmbuild/SRPMS/* + + gitlab-ci-helper: + name: "Gitlab CI trigger helper" + runs-on: ubuntu-latest + env: + SKIP_CI: ${{ (github.event.pull_request.draft == true || contains(github.event.pull_request.labels.*.name, 'WIP')) && !contains(github.event.pull_request.labels.*.name, 'WIP+test') }} + steps: + - name: Write PR status + run: echo "$SKIP_CI" > SKIP_CI.txt + - name: Upload status + uses: actions/upload-artifact@v3 + with: + name: PR_STATUS + path: SKIP_CI.txt diff --git a/.github/workflows/trigger-gitlab.yml b/.github/workflows/trigger-gitlab.yml index 899fef7ed..696d4962d 100644 --- a/.github/workflows/trigger-gitlab.yml +++ b/.github/workflows/trigger-gitlab.yml @@ -13,7 +13,6 @@ jobs: runs-on: ubuntu-latest env: SCHUTZBOT_SSH_KEY: ${{ secrets.SCHUTZBOT_SSH_KEY }} - SKIP_CI: ${{ (github.event.pull_request.draft == true || contains(github.event.pull_request.labels.*.name, 'WIP')) && !contains(github.event.pull_request.labels.*.name, 'WIP+test') }} steps: - name: Report status uses: haya14busa/action-workflow_run-status@v1 @@ -51,6 +50,30 @@ jobs: git checkout ${{ github.event.workflow_run.head_branch }} fi + - name: Download artifacts + uses: actions/github-script@v5 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "PR_STATUS" + })[0]; + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/PR_STATUS.zip`, Buffer.from(download.data)); + + - name: Unzip artifact + run: unzip PR_STATUS.zip + - name: Push to gitlab run: | mkdir -p ~/.ssh @@ -59,5 +82,6 @@ jobs: touch ~/.ssh/known_hosts ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts git remote add ci git@gitlab.com:osbuild/ci/osbuild-composer.git + SKIP_CI=$(cat SKIP_CI.txt) [[ "${SKIP_CI}" == true ]] && PUSH_OPTION='-o ci.variable="SKIP_CI=true"' || PUSH_OPTION="" git push -f ${PUSH_OPTION} ci