From 120018ee52a345ede51256cdb0be54bee3976dcb Mon Sep 17 00:00:00 2001 From: Evgeny Fedin Date: Tue, 15 Nov 2022 10:55:26 +0100 Subject: [PATCH] add weekly-ci action Signed-off-by: Evgeny Fedin --- .github/workflows/weekly_ci.yml | 67 +++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/weekly_ci.yml diff --git a/.github/workflows/weekly_ci.yml b/.github/workflows/weekly_ci.yml new file mode 100644 index 0000000..1c172c2 --- /dev/null +++ b/.github/workflows/weekly_ci.yml @@ -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 }}", + });