Skip to content

Commit

Permalink
ci: setup source-git automation
Browse files Browse the repository at this point in the history
rhel-only

Related: RHEL-36636
  • Loading branch information
jamacku committed May 16, 2024
1 parent 34eefec commit 1f90d0e
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 7 deletions.
17 changes: 17 additions & 0 deletions .github/advanced-commit-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
policy:
cherry-pick:
upstream:
- github: systemd/systemd
exception:
note:
- rhel-only
- RHEL-only
tracker:
- keyword:
- 'Resolves: '
- 'Related: '
- 'Reverts: '
type: jira
issue-format:
- 'RHEL-\d+$'
url: 'https://issues.redhat.com/browse/'
4 changes: 4 additions & 0 deletions .github/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
labels:
dont-merge: dont-merge
manual-merge: pr/needs-manual-merge
target-branch': ['main']
4 changes: 4 additions & 0 deletions .github/pull-request-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
labels:
missing-review: pr/needs-review
changes-requested: pr/changes-requested
missing-failing-ci: pr/needs-ci
1 change: 1 addition & 0 deletions .github/regression-sniffer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
upstream: systemd/systemd
31 changes: 31 additions & 0 deletions .github/tracker-validator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
labels:
missing-tracker: tracker/missing
invalid-product: tracker/invalid-product
invalid-component: tracker/invalid-component
unapproved: tracker/unapproved
products:
- Red Hat Enterprise Linux 10
- CentOS Stream 10
- rhel-10.0.beta
- rhel-10.0
- rhel-10.0.z
- rhel-10.1
- rhel-10.1.z
- rhel-10.2
- rhel-10.2.z
- rhel-10.3
- rhel-10.3.z
- rhel-10.4
- rhel-10.4.z
- rhel-10.5
- rhel-10.5.z
- rhel-10.6
- rhel-10.6.z
- rhel-10.7
- rhel-10.7.z
- rhel-10.8
- rhel-10.8.z
- rhel-10.9
- rhel-10.9.z
- rhel-10.10
- rhel-10.10.z
12 changes: 5 additions & 7 deletions .github/workflows/gather-pr-metadata.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
---

name: Gather Pull Request Metadata

on:
pull_request:
branches: [ main ]
types: [ opened, reopened, synchronize ]
branches: [ main, rhel-10.0.beta, rhel-10.* ]

permissions:
contents: read

jobs:
gather-metadata:
if: github.repository == 'systemd/systemd'
runs-on: ubuntu-22.04
runs-on: ubuntu-latest

steps:
- name: Repository checkout
uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633

- id: metadata
name: Gather Pull Request Metadata
uses: redhat-plumbers-in-action/gather-pull-request-metadata@17821d3bc27c1efed339595898c2e622accc5a1b
uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1

- name: Upload Pull Request Metadata artifact
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
uses: actions/upload-artifact@v4
with:
name: Pull Request Metadata
path: ${{ steps.metadata.outputs.metadata-file }}
retention-days: 1
72 changes: 72 additions & 0 deletions .github/workflows/source-git-automation-on-demand.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Source git Automation Scheduled/On Demand
on:
schedule:
# Workflow runs every 45 minutes
- cron: '*/45 * * * *'
workflow_dispatch:
inputs:
pr-number:
description: 'Pull Request number/s ; when not provided, the workflow will run for all open PRs'
required: true
default: '0'

permissions:
contents: read

jobs:
# Get all open PRs
gather-pull-requests:
if: github.repository == 'redhat-plumbers/systemd-rhel10'
runs-on: ubuntu-latest

outputs:
pr-numbers: ${{ steps.get-pr-numbers.outputs.result }}
pr-numbers-manual: ${{ steps.parse-manual-input.outputs.result }}

steps:
- id: get-pr-numbers
if: inputs.pr-number == '0'
name: Get all open PRs
uses: actions/github-script@v6
with:
# !FIXME: this is not working if there is more than 100 PRs opened
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100
});
return pullRequests.map(pr => pr.number);
- id: parse-manual-input
if: inputs.pr-number != '0'
name: Parse manual input
run: |
# shellcheck disable=SC2086
echo "result="[ ${{ inputs.pr-number }} ]"" >> $GITHUB_OUTPUT
shell: bash

validate-pr:
name: 'Validation of Pull Request #${{ matrix.pr-number }}'
needs: [ gather-pull-requests ]
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
pr-number: ${{ inputs.pr-number == 0 && fromJSON(needs.gather-pull-requests.outputs.pr-numbers) || fromJSON(needs.gather-pull-requests.outputs.pr-numbers-manual) }}

permissions:
# required for merging PRs
contents: write
# required for PR comments and setting labels
pull-requests: write

steps:
- name: Source-git Automation
uses: redhat-plumbers-in-action/source-git-automation@v1
with:
pr-number: ${{ matrix.pr-number }}
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/source-git-automation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Source git Automation
on:
workflow_run:
workflows: [ Gather Pull Request Metadata ]
types:
- completed

permissions:
contents: read

jobs:
download-metadata:
if: >
github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.repository == 'redhat-plumbers/systemd-rhel10'
runs-on: ubuntu-latest

outputs:
pr-metadata: ${{ steps.Artifact.outputs.pr-metadata-json }}

steps:
- id: Artifact
name: Download Artifact
uses: redhat-plumbers-in-action/download-artifact@v1
with:
name: Pull Request Metadata

source-git-automation:
needs: [ download-metadata ]
runs-on: ubuntu-latest

permissions:
# required for merging PRs
contents: write
# required for PR comments and setting labels
pull-requests: write

steps:
- name: Source-git Automation
uses: redhat-plumbers-in-action/source-git-automation@v1
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
jira-api-token: ${{ secrets.JIRA_API_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 1f90d0e

Please sign in to comment.