Skip to content

e2e-owners-9bfa967-3a17e20f2efb470ebc65455be1d65ca5-an-owners-file-is-submitted-by-redhat #3070

e2e-owners-9bfa967-3a17e20f2efb470ebc65455be1d65ca5-an-owners-file-is-submitted-by-redhat

e2e-owners-9bfa967-3a17e20f2efb470ebc65455be1d65ca5-an-owners-file-is-submitted-by-redhat #3070

Workflow file for this run

name: Red Hat OWNERS Files
# On OWNERS file submissions, this workflow will check the path and the
# contents of the file to make sure it matches expectations for Red Hat
# submissions.
on:
pull_request_target:
paths:
- charts/redhat/**/OWNERS
- charts/community/redhat/**/OWNERS
env:
SUCCESS_LABEL: redhat-owners-content-ok
jobs:
gather-metadata:
name: Gather Metadata From Path
outputs:
category: ${{ steps.gather-metadata.outputs.category }}
organization: ${{ steps.gather-metadata.outputs.organization }}
chartname: ${{ steps.gather-metadata.outputs.chart-name }}
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
steps:
- name: Clean up stale label
uses: actions/github-script@v7
continue-on-error: true
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const successLabel = process.env.SUCCESS_LABEL;
try {
await github.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: successLabel,
})
} catch (error) {
// a 404 indicates the label isn't here
if (error.status == 404) {
console.log('The issue did not have the label');
return 0;
}
throw error
}
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: ./.github/actions/setup-python
- name: Install Python CI tooling
working-directory: scripts
run: |
make venv.tools
- name: Gather Metadata
id: gather-metadata
env:
API_URL: ${{ github.event.pull_request._links.self.href }}
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
./scripts/venv.tools/bin/extract-metadata-from-pr \
--emit-to-github-output \
"${API_URL}"
ensure-prefix-in-path:
name: Ensure chart name prefix
runs-on: ubuntu-24.04
permissions:
contents: read
needs: [gather-metadata]
steps:
- name: Confirm Prefix
id: confirm-prefix
env:
CHART_NAME: ${{ needs.gather-metadata.outputs.chartname }}
run: echo "${CHART_NAME}" | grep "^redhat-"
ensure-owners-file-contents:
name: Ensure OWNERS file contents is valid
runs-on: ubuntu-24.04
permissions:
contents: read
needs: [gather-metadata]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: ./.github/actions/setup-python
- name: Install Python CI tooling
working-directory: scripts
run: |
make venv.tools
# Only used to assert content of the OWNERS file.
- name: Checkout Pull Request
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0
path: "pr-branch"
- name: Assert Owners File Content
id: assert-content
working-directory: pr-branch
env:
CATEGORY: ${{ needs.gather-metadata.outputs.category }}
ORGANIZATION: ${{ needs.gather-metadata.outputs.organization }}
CHARTNAME: ${{ needs.gather-metadata.outputs.chartname }}
run: |
../scripts/venv.tools/bin/assert-redhat-owners-file-meta \
"${CATEGORY}" \
"${ORGANIZATION}" \
"${CHARTNAME}"
notify-on-failure:
name: Notify on failure
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
needs: [ensure-prefix-in-path, ensure-owners-file-contents]
if: failure() && (needs.ensure-prefix-in-path.result == 'failure' || needs.ensure-owners-file-contents.result == 'failure')
steps:
- name: Send PR Comment
uses: actions/github-script@v7
env:
PREFIX_CHECK_RESULT: ${{ needs.ensure-prefix-in-path.result != '' && needs.ensure-prefix-in-path.result || 'unknown' }}
CONTENT_CHECK_RESULT: ${{ needs.ensure-owners-file-contents.result != '' && needs.ensure-owners-file-contents.result || 'unknown' }}
BUILD_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prefixCheckResult = process.env.PREFIX_CHECK_RESULT;
const contentCheckResult = process.env.CONTENT_CHECK_RESULT;
const buildURL = process.env.BUILD_URL;
var comment = '### :x: Red Hat OWNERS File Content and Path Check';
if (prefixCheckResult == 'failure') {
comment = comment.concat('\n\n', 'The chart name in your submission path looks incorrect!');
}
if (contentCheckResult == 'failure') {
comment = comment.concat('\n\n', 'The content of your OWNERS file looks incorrect!');
}
comment = comment.concat('\n\n', `Check your [workflow run](${buildURL}) for more information.`);
var issue_number = process.env.GITHUB_EVENT_NUMBER;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: Number(issue_number),
body: comment
});
label-on-success:
name: Label On Success
continue-on-error: true
needs: [ensure-prefix-in-path, ensure-owners-file-contents]
runs-on: ubuntu-24.04
permissions:
contents: read
pull-requests: write
env:
PR: ${{ github.event.number }}
if: success()
steps:
- name: Label PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue_number = process.env.PR;
const successLabel = process.env.SUCCESS_LABEL;
github.rest.issues.addLabels({
issue_number: Number(issue_number),
owner: context.repo.owner,
repo: context.repo.repo,
labels: [successLabel],
});