github workflows: modify Gitlab CI trigger
In 5e639cba6f the context of the Trigger
Gitalb CI workflow changed and the context
"github.event.pull_request.draft" is no longer available so the
condition for SKIP_CI didn't work. This can be fixed by getting the
variable in the previous workflow and passin it as artifact. Docs:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#using-data-from-the-triggering-workflow
This commit is contained in:
parent
d8ea259f8b
commit
c91131ee0c
2 changed files with 39 additions and 1 deletions
14
.github/workflows/tests.yml
vendored
14
.github/workflows/tests.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
26
.github/workflows/trigger-gitlab.yml
vendored
26
.github/workflows/trigger-gitlab.yml
vendored
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue