Skip to content

Commit

Permalink
CI updates
Browse files Browse the repository at this point in the history
This is done by the automated script named upgrade-c2cciutils-to-1.7
  • Loading branch information
sbrunner committed Jan 26, 2024
1 parent 3801fb2 commit ed39587
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 59 deletions.
11 changes: 7 additions & 4 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@
matchPackageNames: ['shellcheck-py/shellcheck-py'],
versioning: 'regex:^v(?<major>\\d+)\\.(?<minor>\\d+)\\.(?<patch>\\d+)\\.(?<build>\\d+)$',
},
/** Auto merge the GitHub action and pre-commit updates */
/** Auto merge updates on CI files */
{
matchDatasources: ['github-actions', 'pre-commit'],
matchPaths: ['^\\.pre-commit-config\\.yaml$', '^\\.github/.*', '^ci/.*'],
automerge: true,
},
/** Auto merge updates on CI files */
/** Group and auto merge the CI dependencies */
{
matchPaths: ['^\\.pre-commit-config\\.yaml$', '^\\.github/.*', '^ci/.*'],
matchFileNames: ['.github/**', '.pre-commit-config.yaml', 'ci/**'],
groupName: 'CI dependencies',
automerge: true,
separateMajorMinor: false,
separateMinorPatch: false,
},
],
}
23 changes: 0 additions & 23 deletions .github/workflows/delete-old-workflow-run.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/delete-old-workflows-run.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ env:

jobs:
build:
name: Delete old workflow runs
runs-on: ubuntu-22.04
timeout-minutes: 25
name: Delete old workflow runs

steps:
- name: Delete old workflow runs
Expand Down
26 changes: 0 additions & 26 deletions .github/workflows/dependency-auto-review.yaml

This file was deleted.

5 changes: 2 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ jobs:
if: failure()
- name: Print environment information
run: c2cciutils-env

env:
GITHUB_EVENT: ${{ toJson(github) }}

Expand Down Expand Up @@ -86,8 +85,6 @@ jobs:
if: matrix.helm == 'latest'

- name: Trigger changelog workflow
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/github-script@v7
with:
script: |-
Expand All @@ -99,3 +96,5 @@ jobs:
event_type: 'changelog',
});
}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .github/workflows/pr-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ on:
types:
- opened
- reopened
- labeled
- unlabeled
- edited
- synchronize

Expand Down
110 changes: 110 additions & 0 deletions .github/workflows/pull-request-automation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Auto reviews, merge and close pull requests

on:
pull_request:
types:
- opened
- reopened
- closed
pull_request_target:
types:
- closed

jobs:
auto-merge:
name: Auto reviews, merge and close pull requests
runs-on: ubuntu-22.04
timeout-minutes: 5

steps:
- name: Print event
run: echo "${GITHUB}" | jq
env:
GITHUB: ${{ toJson(github) }}
- name: Print context
uses: actions/github-script@v7
with:
script: |-
console.log(context);
- name: Auto reviews Renovate updates
uses: actions/github-script@v7
with:
script: |-
github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
event: 'APPROVE',
})
if: |-
github.event.pull_request.user.login == 'renovate[bot]'
&& (github.event.action == 'opened'
|| github.event.action == 'reopened')
- name: Auto review and merge snyk auto fix
uses: actions/github-script@v7
with:
script: |-
github.rest.pulls.createReview({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
event: 'APPROVE',
});
github.graphql(`
mutation {
enablePullRequestAutoMerge(input: {
pullRequestId: "${context.payload.pull_request.node_id}",
mergeMethod: SQUASH,
}) {
pullRequest {
autoMergeRequest {
enabledAt
}
}
}
}
`)
if: |-
github.event.pull_request.user.login == 'c2c-bot-gis-ci'
&& startsWith(github.head_ref, 'snyk-fix/')
&& (github.event.action == 'opened'
|| github.event.action == 'reopened')
- name: Restart audit workflow
uses: actions/github-script@v7
with:
script: |-
let runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'audit.yaml',
per_page: 1,
});
runs = runs.data.workflow_runs;
if (runs.length == 1 && runs[0].status != 'success') {
console.log(`Rerun workflow ${runs[0].id} ${runs[0].status}`);
github.rest.actions.reRunWorkflowFailedJobs({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: runs[0].id,
});
}
if: |-
github.event.pull_request.user.login == 'c2c-bot-gis-ci'
&& (startsWith(github.head_ref, 'snyk-fix/')
|| startsWith(github.head_ref, 'dpkg-update/'))
&& github.event.action == 'closed'
&& github.event.pull_request.merged == true
- name: Auto close pre-commit.ci autoupdate
uses: actions/github-script@v7
with:
script: |-
github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
state: 'closed',
});
if: |-
github.event.pull_request.user.login == 'pre-commit-ci'
&& (github.event.action == 'opened'
|| github.event.action == 'reopened')

0 comments on commit ed39587

Please sign in to comment.