Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/create-doc-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Create Documentation Issue on PR Approval

on:
pull_request_review:
types:
- submitted # Normal trigger on PR approval

workflow_dispatch: # Allows manual triggering for testing
inputs:
pr_number:
description: 'Test PR Number'
required: true
default: '9999'
pr_title:
description: 'Test PR Title'
required: true
default: 'Test PR for Documentation Updates'

jobs:
create-issue:
runs-on: ubuntu-latest
steps:
- name: Fetch PR Data (For PR-Triggered Runs)
id: fetch-pr
if: github.event_name == 'pull_request_review'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const pr = context.payload.pull_request;
const labels = pr.labels.map(label => label.name);

if (!labels.includes('needs-docs')) {
console.log('PR does not have the needs-docs label. Skipping issue creation.');
core.setOutput('should_create_issue', 'false');
} else {
core.setOutput('should_create_issue', 'true');
core.setOutput('pr_number', pr.number);
core.setOutput('pr_title', pr.title);
core.setOutput('pr_url', pr.html_url);
}

- name: Use Test Data for Manual Runs
id: test-data
if: github.event_name == 'workflow_dispatch'
run: |
echo "should_create_issue=true" >> $GITHUB_ENV
echo "pr_number=${{ inputs.pr_number }}" >> $GITHUB_ENV
echo "pr_title=${{ inputs.pr_title }}" >> $GITHUB_ENV
echo "pr_url=https://github.com/stacklok/codegate/pull/${{ inputs.pr_number }}" >> $GITHUB_ENV

- name: Create Issue in Documentation Repo
if: env.should_create_issue == 'true'
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const repoOwner = 'stacklok';
const repoName = 'codegate-docs';

const issueTitle = `Docs update needed for PR #${process.env.pr_number}`;
const issueBody = `A documentation update is needed for the following PR:\n\n${process.env.pr_url}\n\n**Summary:**\n${process.env.pr_title}`;

github.rest.issues.create({
owner: repoOwner,
repo: repoName,
title: issueTitle,
body: issueBody,
labels: ['documentation']
});