add weekly-ci action

Signed-off-by: Evgeny Fedin <efedin@redhat.com>
This commit is contained in:
Evgeny Fedin 2022-11-15 10:55:26 +01:00 committed by Richard Megginson
parent 0884e24849
commit 120018ee52

67
.github/workflows/weekly_ci.yml vendored Normal file
View file

@ -0,0 +1,67 @@
# yamllint disable rule:line-length
name: Weekly CI trigger
on: # yamllint disable-line rule:truthy
workflow_dispatch:
schedule:
- cron: '0 13 * * 6'
env:
BRANCH_NAME: "weekly-ci"
COMMIT_MESSAGE: "Weekly CI check"
COMMENT: "[citest]"
jobs:
weekly_ci:
runs-on: ubuntu-latest
steps:
- name: Delete the previous branch if exists
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.rest.git.listMatchingRefs({
owner: context.repo.owner,
repo: context.repo.repo,
branch: "heads/${{ env.BRANCH_NAME }}",
});
for (ref in response.data){
if (response.data[ref].ref == "refs/heads/${{ env.BRANCH_NAME }}"){
console.log("deleting branch");
console.log(response.data[ref]);
await github.rest.git.deleteRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "heads/${{ env.BRANCH_NAME }}",
});
}
}
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Create and push empty commit
run: |
set -euxo pipefail
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git checkout -b weekly-ci
git commit --allow-empty -m "${{ env.COMMIT_MESSAGE }}"
git push --set-upstream origin ${{ env.BRANCH_NAME }}
- name: Create and comment pull request
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GH_PUSH_TOKEN }}
script: |
const response = await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: "${{ env.COMMIT_MESSAGE }}",
head: "${{ env.BRANCH_NAME }}",
base: context.ref
});
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: response.data.number,
body: "${{ env.COMMENT }}",
});