Skip to content

Commit

Permalink
Request a dispatched build for periodical jobs (#17657)
Browse files Browse the repository at this point in the history
* Request a dispatched build for periodical jobs

Automatically created PRs do not trigger other workflows
by default.
Request a dispatched PR build manually to overcome this.

Also change the cron schedule to run these jobs only on workdays.

* Fix if condition

* fix dispatch

* Fix variable

* add token

* sync gh dispatch code and update create-pull-request deps
  • Loading branch information
mpfz0r authored Dec 13, 2023
1 parent 482866d commit a815152
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/fix-linter-hints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Fix linter hints

on:
schedule:
- cron: '0 */8 * * *'
- cron: '0 */8 * * MON-FRI'

workflow_dispatch:

Expand Down Expand Up @@ -46,7 +46,8 @@ jobs:
run: |
/bin/sh ../.github/scripts/web-code-quality.sh | curl -X POST -H 'Content-Type: application/json' -d @- ${{ secrets.DEV_METRICS_URL }}
- name: Create/Update Pull Request
uses: Graylog2/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad
id: pr-create
uses: Graylog2/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
title: Fixing linter hints automatically
body: This PR was created by a job that is running periodically to find and fix linter hints.
Expand All @@ -55,3 +56,26 @@ jobs:
committer: Dr. Lint-a-lot <[email protected]>
commit-message: Running lint --fix
delete-branch: true

- name: Get headRef and SHA of PR
id: pr-infos
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: |
HEADREF=$(gh pr view ${{ steps.pr-create.outputs.pull-request-number }} --json headRefName --template '{{.headRefName}}')
echo "sha=$(git rev-parse origin/$HEADREF)" >> $GITHUB_OUTPUT
echo "headref=$HEADREF" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}

- name: Request dispatched PR build
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: >
gh workflow run -R Graylog2/graylog-project-internal pr-build.yml --ref master
-f caller_repo=${{ github.repository }}
-f caller_pr_nr=${{ steps.pr-create.outputs.pull-request-number }}
-f caller_base_branch=master
-f caller_head_branch=${{ steps.pr-infos.outputs.headref }}
-f head_sha=${{ steps.pr-infos.outputs.sha }}
-f initial_actor="Dr. Lint-a-lot"
env:
GITHUB_TOKEN: ${{ secrets.PAT_GRAYLOG_PROJECT_INTERNAL_WORKFLOW_RW }}
28 changes: 26 additions & 2 deletions .github/workflows/update-browserslist-db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Update browserslist DB.

on:
schedule:
- cron: '0 0 1/14 * *'
- cron: '0 0 1/14 * MON-FRI'

workflow_dispatch:

Expand All @@ -21,7 +21,8 @@ jobs:
continue-on-error: true
run: npx browserslist@latest --update-db
- name: Create/Update Pull Request
uses: Graylog2/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad
id: pr-create
uses: Graylog2/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
title: Updating browserslist DB.
body: This PR was created by a job that is running periodically to update the browserslist db automatically. See [here](https://github.com/browserslist/browserslist#browsers-data-updating) for details.
Expand All @@ -30,3 +31,26 @@ jobs:
committer: Dr. Lint-a-lot <[email protected]>
commit-message: Updating browserslist DB.
delete-branch: true

- name: Get headRef and SHA of PR
id: pr-infos
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: |
HEADREF=$(gh pr view ${{ steps.pr-create.outputs.pull-request-number }} --json headRefName --template '{{.headRefName}}')
echo "sha=$(git rev-parse origin/$HEADREF)" >> $GITHUB_OUTPUT
echo "headref=$HEADREF" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}

- name: Request dispatched PR build
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: >
gh workflow run -R Graylog2/graylog-project-internal pr-build.yml --ref master
-f caller_repo=${{ github.repository }}
-f caller_pr_nr=${{ steps.pr-create.outputs.pull-request-number }}
-f caller_base_branch=master
-f caller_head_branch=${{ steps.pr-infos.outputs.headref }}
-f head_sha=${{ steps.pr-infos.outputs.sha }}
-f initial_actor="Dr. Lint-a-lot"
env:
GITHUB_TOKEN: ${{ secrets.PAT_GRAYLOG_PROJECT_INTERNAL_WORKFLOW_RW }}
28 changes: 26 additions & 2 deletions .github/workflows/updating-lockfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Updating yarn lockfile

on:
schedule:
- cron: '0 */12 * * *'
- cron: '0 */12 * * MON-FRI'

workflow_dispatch:

Expand All @@ -18,7 +18,8 @@ jobs:
- name: Install dependencies
run: yarn install
- name: Create/Update Pull Request
uses: Graylog2/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad
id: pr-create
uses: Graylog2/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
with:
title: Updating yarn lockfile
body: This PR was created by a job that is running periodically to update the yarn lockfile after transitive dependencies have been updated.
Expand All @@ -27,3 +28,26 @@ jobs:
committer: Gary Bot <[email protected]>
commit-message: Updating yarn lockfile
delete-branch: true

- name: Get headRef and SHA of PR
id: pr-infos
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: |
HEADREF=$(gh pr view ${{ steps.pr-create.outputs.pull-request-number }} --json headRefName --template '{{.headRefName}}')
echo "sha=$(git rev-parse origin/$HEADREF)" >> $GITHUB_OUTPUT
echo "headref=$HEADREF" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}

- name: Request dispatched PR build
if: ${{ steps.pr-create.outputs.pull-request-operation != 'closed' }}
run: >
gh workflow run -R Graylog2/graylog-project-internal pr-build.yml --ref master
-f caller_repo=${{ github.repository }}
-f caller_pr_nr=${{ steps.pr-create.outputs.pull-request-number }}
-f caller_base_branch=master
-f caller_head_branch=${{ steps.pr-infos.outputs.headref }}
-f head_sha=${{ steps.pr-infos.outputs.sha }}
-f initial_actor="Dr. Lint-a-lot"
env:
GITHUB_TOKEN: ${{ secrets.PAT_GRAYLOG_PROJECT_INTERNAL_WORKFLOW_RW }}

0 comments on commit a815152

Please sign in to comment.