The purpose of this action is to offer reliable validator Red Hat trackers like Bugzilla and JIRA.
- product, component and flags validation
- feedback in form of labels and status check directly on Pull Requests
name: Gather Pull Request Metadata
on:
pull_request:
types: [ opened, reopened, synchronize ]
branches: [ main ]
permissions:
contents: read
jobs:
gather-metadata:
runs-on: ubuntu-latest
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
- name: Upload artifact with gathered metadata
uses: actions/upload-artifact@v3
with:
name: pr-metadata
path: ${{ steps.Metadata.outputs.metadata-file }}
name: Tracker Validator
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'
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: pr-metadata
commit-linter:
needs: [ download-metadata ]
runs-on: ubuntu-latest
outputs:
validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
permissions:
# required for creation of checks
checks: write
# required for PR comments and set labels
pull-requests: write
steps:
- id: commit-linter
name: Lint Commits
uses: redhat-plumbers-in-action/advanced-commit-linter@v1
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
token: ${{ secrets.GITHUB_TOKEN }}
tracker-validator:
needs: [ download-metadata, commit-linter ]
runs-on: ubuntu-latest
outputs:
validated-pr-metadata: ${{ steps.commit-linter.outputs.validated-pr-metadata }}
permissions:
# required for creation of checks
checks: write
# required for PR comments and set labels
pull-requests: write
steps:
- name: Get Tracker ID
run:
validated-pr-metadata
- id: tracker-validator
name: Validate Tracker
uses: redhat-plumbers-in-action/tracker-validator@v1
with:
pr-metadata: ${{ needs.download-metadata.outputs.pr-metadata }}
product: Red Hat Enterprise Linux 9
component: systemd
tracker: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.id }}
tracker-type: ${{ fromJSON(needs.commit-linter.outputs.validated-pr-metadata).validation.tracker.type }}
bugzilla-instance: https://bugzilla.stage.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 }}
Action currently accepts the following options:
# ...
- uses: redhat-plumbers-in-action/tracker-validator@v1
with:
pr-metadata: <pr-metadata.json>
config-path: <path to config file>
tracker: <tracker ID>
tracker-type: <tracker type>
product: <product name>
component: <component name>
bugzilla-instance: <Bugzilla instance URL>
bugzilla-api-token: <Bugzilla API token>
jira-instance: <Jira instance URL>
jiira-api-token: <Jira API token>
set-status: <true or false>
status-title: <status title>
token: <GitHub token or PAT>
# ...
Stringified JSON Pull Request metadata provided by GitHub Action redhat-plumbers-in-action/gather-pull-request-metadata
.
Pull Request metadata has the following format: metadata format
- default value:
undefined
- requirements:
required
Path to configuration file. Configuration file format is described in: Configuration section.
- default value:
.github/tracker-validator.yml
- requirements:
optional
The tracker identificator. For example, for Bugzilla: tracker: 1234567
.
- default value:
undefined
- requirements:
required
The tracker type. Currently supported: bugzilla
and jira
.
- default value:
undefined
- requirements:
required
Component name is used for validation if provided tracker is targeting the expected component. For example, for Bugzilla: component: systemd
. If component is not provided, validation will be skipped.
- default value:
undefined
- requirements:
optional
The URL of the Bugzilla instance on which will be performed API requests and validation of trackers. For example: bugzilla-instance: https://bugzilla.redhat.com
.
- default value:
undefined
- requirements:
optional
The Bugzilla API token is used for performing API requests. The token should be stored as GitHub secret. Never paste the token directly into the workflow file.
- default value:
undefined
- requirements:
optional
The URL of the Jira instance on which will be performed API requests and validation of trackers. For example: jira-instance: https://issues.redhat.com
.
- default value:
undefined
- requirements:
required
The Jira API token is used for performing API requests. The token should be stored as GitHub secret. Never paste the token directly into the workflow file.
- default value:
undefined
- requirements:
optional
Set status on Pull Request. If enabled, Action will create check-run status with validation results.
- default value:
false
- requirements:
optional
Optional H3 title of status message.
- default value:
Tracker validation
- requirements:
optional
GitHub token or PAT is used for creating comments on Pull Request and setting checks.
# required permission
permissions:
checks: write
pull-requests: write
- default value:
undefined
- requirements:
required
- recomended value:
secrets.GITHUB_TOKEN
labels:
missing-tracker: tracker/missing
invalid-product: tracker/invalid-product
invalid-component: tracker/invalid-component
unapproved: tracker/unapproved
products: []
Allows you to set custom labels for certain conditions. When no value is provided, default value is used.
Name of the label which will be set when tracker is missing.
- default value:
tracker/missing
Name of the label which will be set when tracker is targeting invalid product.
- default value:
tracker/invalid-product
Name of the label which will be set when tracker is targeting invalid component.
- default value:
tracker/invalid-component
Name of the label which will be set when tracker is not approved.
- default value:
tracker/unapproved
Product name is used for validation if provided tracker is targeting the expected product. For example, for Bugzilla: product: Red Hat Enterprise Linux 9
. If product is not provided, validation will be skipped.
- default value:
undefined
- requirements:
optional
Message with status of Tracker validation.
- Status checks from Pull Request Validator are randomly assigned to check suites, GitHub API for check suites doesn't provide a way to assign a check to a specific suite.