-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* on schedule and on demand workflows * Added Tracker validation for Bugzilla and Jira rhel-only Resolves: RHEL-1087
- Loading branch information
Showing
3 changed files
with
139 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
labels: | ||
missing-tracker: tracker/missing | ||
invalid-product: tracker/invalid-product | ||
invalid-component: tracker/invalid-component | ||
unapproved: tracker/unapproved | ||
products: | ||
- CentOS Stream 8 | ||
- rhel-8.2.0 | ||
- rhel-8.4.0 | ||
- rhel-8.6.0 | ||
- rhel-8.8.0 | ||
- rhel-8.9.0 | ||
- rhel-8.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
--- | ||
|
||
name: Source git Automation Scheduled/On Demand | ||
on: | ||
schedule: | ||
# Workflow runs every 15 minutes | ||
- cron: '*/15 * * * *' | ||
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-rhel8' | ||
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: | | ||
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: | ||
statuses: write | ||
checks: write | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Repository checkout | ||
uses: actions/checkout@v3 | ||
|
||
- id: metadata | ||
name: Gather Pull Request Metadata | ||
uses: redhat-plumbers-in-action/gather-pull-request-metadata@v1 | ||
with: | ||
pr-number: ${{ matrix.pr-number }} | ||
|
||
- id: commit-linter | ||
name: Lint Commits | ||
uses: redhat-plumbers-in-action/advanced-commit-linter@v2 | ||
with: | ||
pr-metadata: ${{ steps.metadata.outputs.metadata }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# Validates tracker, changes tracker status, updates PR title | ||
- id: tracker-validator | ||
name: Validate Tracker | ||
uses: redhat-plumbers-in-action/tracker-validator@v1 | ||
with: | ||
pr-metadata: ${{ steps.metadata.outputs.metadata }} | ||
component: systemd | ||
tracker: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }} | ||
tracker-type: ${{ fromJSON(steps.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }} | ||
bugzilla-instance: https://bugzilla.redhat.com | ||
bugzilla-api-token: ${{ secrets.BUGZILLA_API_TOKEN }} | ||
jira-instance: https://issues.redhat.com | ||
jira-api-token: ${{ secrets.JIRA_API_TOKEN }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
# TODO: merge PR if all checks passed | ||
# TODO: add comment to Tracker that PR was merged ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters