18
.github/CODEOWNERS
vendored
18
.github/CODEOWNERS
vendored
@@ -3,26 +3,8 @@
|
||||
# https://docs.github.com/articles/about-codeowners
|
||||
# https://git-scm.com/docs/gitignore
|
||||
|
||||
# Engineering
|
||||
*.js @github/docs-engineering
|
||||
*.ts @github/docs-engineering
|
||||
*.tsx @github/docs-engineering
|
||||
/.github/ @github/docs-engineering
|
||||
/script/ @github/docs-engineering
|
||||
/includes/ @github/docs-engineering
|
||||
Dockerfile @github/docs-engineering
|
||||
package-lock.json @github/docs-engineering
|
||||
package.json @github/docs-engineering
|
||||
|
||||
# Site Policy
|
||||
/content/site-policy/ @github/site-policy-admins
|
||||
|
||||
# Content strategy
|
||||
/contributing/content-markup-reference.md @github/docs-content-strategy
|
||||
/contributing/content-style-guide.md @github/docs-content-strategy
|
||||
/contributing/content-model.md @github/docs-content-strategy
|
||||
/contributing/content-style-guide.md @github/docs-content-strategy
|
||||
/contributing/content-templates.md @github/docs-content-strategy
|
||||
|
||||
# Requires review of #actions-oidc-integration, docs-engineering/issues/1506
|
||||
content/actions/deployment/security-hardening-your-deployments/** @github/oidc
|
||||
|
||||
15
.github/labeler.yml
vendored
15
.github/labeler.yml
vendored
@@ -1,15 +0,0 @@
|
||||
engineering:
|
||||
- lib/*
|
||||
- lib/**/*
|
||||
- middleware/*
|
||||
- middleware/**/*
|
||||
- tests/*
|
||||
- tests/**/*
|
||||
- stylesheets/*
|
||||
- stylesheets/**/*
|
||||
- script/*
|
||||
- script/**/*
|
||||
- components/*
|
||||
- components/**/*
|
||||
- pages/*
|
||||
- pages/**/*
|
||||
22
.github/workflows/auto-label-prs.yml
vendored
22
.github/workflows/auto-label-prs.yml
vendored
@@ -1,22 +0,0 @@
|
||||
name: Auto label Pull Requests
|
||||
|
||||
# **What it does**: Automatically adds the engineering label when specific files change.
|
||||
# **Why we have it**: Other automation applies specifically to engineering label issues and pull requests.
|
||||
# **Who does it impact**: Automation that relies on the engineering label.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
if: github.repository == 'github/docs-internal'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# See labeling configuration in the `.github/labeler.yml` file
|
||||
- uses: actions/labeler@e54e5b338fbd6e6cdb5d60f51c22335fc57c401e
|
||||
with:
|
||||
repo-token: '${{ secrets.GITHUB_TOKEN }}'
|
||||
21
.github/workflows/codeowners-content-strategy.yml
vendored
Normal file
21
.github/workflows/codeowners-content-strategy.yml
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
name: Codeowners - Content Strategy
|
||||
|
||||
# **What it does**: Automatically add reviewers based on paths, but only for the docs-internal repo.
|
||||
# **Why we have it**: So we can have reviewers automatically without getting open source notifications.
|
||||
# **Who does it impact**: Docs team.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '/contributing/content-*.md'
|
||||
|
||||
jobs:
|
||||
codeowners-content-strategy:
|
||||
if: ${{ github.repository == 'github/docs-internal' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add Content Strategy as a reviewer
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.DOCS_BOT_FR }}
|
||||
PR: ${{ github.event.pull_request.html_url }}
|
||||
run: gh pr edit $PR --add-reviewer github/docs-content-strategy
|
||||
29
.github/workflows/codeowners-docs-engineering.yml
vendored
Normal file
29
.github/workflows/codeowners-docs-engineering.yml
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
name: Codeowners - Docs Engineering
|
||||
|
||||
# **What it does**: Automatically add reviewers based on paths, but only for the docs-internal repo.
|
||||
# And sets the 'engineering' label on the PR.
|
||||
# **Why we have it**: So we can have reviewers automatically without getting open source notifications.
|
||||
# **Who does it impact**: Docs team.
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths:
|
||||
- '**.js'
|
||||
- '**.ts'
|
||||
- '**.tsx'
|
||||
- '**.scss'
|
||||
- 'src/**'
|
||||
- '.github/**'
|
||||
- '**Dockerfile'
|
||||
- 'package*.json'
|
||||
|
||||
jobs:
|
||||
codeowners-docs-engineering:
|
||||
if: ${{ github.repository == 'github/docs-internal' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Add Docs Engineering as a reviewer
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.DOCS_BOT_FR }}
|
||||
PR: ${{ github.event.pull_request.html_url }}
|
||||
run: gh pr edit $PR --add-reviewer github/docs-engineering --add-label engineering
|
||||
@@ -5,7 +5,7 @@ import events from '../../src/events/middleware.js'
|
||||
import anchorRedirect from '../../src/rest/api/anchor-redirect.js'
|
||||
import search from '../../src/search/middleware/search.js'
|
||||
import pageInfo from '../../src/pageinfo/middleware.js'
|
||||
import webhooks from './webhooks.js'
|
||||
import webhooks from '../../src/webhooks/middleware/webhooks.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ export default {
|
||||
webpack: (config) => {
|
||||
config.experiments = config.experiments || {}
|
||||
config.experiments.topLevelAwait = true
|
||||
config.resolve.fallback = { fs: false }
|
||||
return config
|
||||
},
|
||||
|
||||
|
||||
@@ -1,114 +1,4 @@
|
||||
import { GetServerSideProps } from 'next'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
import { getInitialPageWebhooks } from 'src/webhooks/lib'
|
||||
import { getMainContext, MainContext, MainContextT } from 'components/context/MainContext'
|
||||
import {
|
||||
getAutomatedPageContextFromRequest,
|
||||
AutomatedPageContext,
|
||||
AutomatedPageContextT,
|
||||
} from 'components/context/AutomatedPageContext'
|
||||
import { WebhookAction } from 'components/webhooks/types'
|
||||
import { Webhook } from 'components/webhooks/Webhook'
|
||||
import { getAutomatedPageMiniTocItems } from 'lib/get-mini-toc-items'
|
||||
import { AutomatedPage } from 'components/article/AutomatedPage'
|
||||
|
||||
type Props = {
|
||||
mainContext: MainContextT
|
||||
automatedPageContext: AutomatedPageContextT
|
||||
webhooks: WebhookAction[]
|
||||
}
|
||||
|
||||
export default function WebhooksEventsAndPayloads({
|
||||
mainContext,
|
||||
automatedPageContext,
|
||||
webhooks,
|
||||
}: Props) {
|
||||
const router = useRouter()
|
||||
const { locale } = router
|
||||
const content = webhooks.map((webhook: WebhookAction, index) => {
|
||||
return (
|
||||
<div key={`${webhook.data.requestPath}-${index}`}>
|
||||
<Webhook webhook={webhook} />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
// When someone clicks on a minitoc hash anchor link on this page, we want to
|
||||
// remove the type query parameter from the URL because the type won't make
|
||||
// sense anymore (e.g. ?actionTtype=closed#issues and you click on the fork minitoc
|
||||
// we don't want the URL to be ?actionType=closed#fork).
|
||||
useEffect(() => {
|
||||
const hashChangeHandler = () => {
|
||||
const { asPath } = router
|
||||
let [pathRoot, pathQuery = ''] = asPath.split('?')
|
||||
|
||||
if (pathRoot.includes('#')) {
|
||||
pathRoot = pathRoot.split('#')[0]
|
||||
}
|
||||
|
||||
// carry over any other query parameters besides `actionType` for the webhook
|
||||
// action type
|
||||
if (pathQuery.includes('#')) {
|
||||
pathQuery = pathQuery.split('#')[0]
|
||||
}
|
||||
const params = new URLSearchParams(pathQuery)
|
||||
params.delete('actionType')
|
||||
|
||||
if (location.hash) {
|
||||
router.replace(
|
||||
{ pathname: pathRoot, query: params.toString(), hash: location.hash },
|
||||
undefined,
|
||||
{
|
||||
shallow: true,
|
||||
locale,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', hashChangeHandler)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('hashchange', hashChangeHandler)
|
||||
}
|
||||
}, [locale])
|
||||
|
||||
return (
|
||||
<MainContext.Provider value={mainContext}>
|
||||
<AutomatedPageContext.Provider value={automatedPageContext}>
|
||||
<AutomatedPage>{content}</AutomatedPage>
|
||||
</AutomatedPageContext.Provider>
|
||||
</MainContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
|
||||
const req = context.req as object
|
||||
const res = context.res as object
|
||||
const currentVersion = context.query.versionId as string
|
||||
const mainContext = await getMainContext(req, res)
|
||||
const { miniTocItems } = getAutomatedPageContextFromRequest(req)
|
||||
|
||||
// Get data for initial webhooks page (i.e. only 1 action type per webhook and
|
||||
// no nested parameters)
|
||||
const webhooks = (await getInitialPageWebhooks(currentVersion)) as WebhookAction[]
|
||||
|
||||
// Build the minitocs for the webhooks page which is based on the webhook
|
||||
// categories in addition to the Markdown in the webhook-events-and-payloads.md
|
||||
// content file
|
||||
const webhooksMiniTocs = await getAutomatedPageMiniTocItems(
|
||||
webhooks.map((webhook) => webhook.data.category),
|
||||
context
|
||||
)
|
||||
webhooksMiniTocs && miniTocItems.push(...webhooksMiniTocs)
|
||||
|
||||
return {
|
||||
props: {
|
||||
webhooks,
|
||||
mainContext,
|
||||
automatedPageContext: getAutomatedPageContextFromRequest(req),
|
||||
},
|
||||
}
|
||||
}
|
||||
export {
|
||||
default,
|
||||
getServerSideProps,
|
||||
} from '../../../../src/webhooks/pages/webhook-events-and-payloads'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Parameter, StatusCode, CodeSample, BodyParameter } from '../rest/types'
|
||||
import { Parameter, StatusCode, CodeSample, BodyParameter } from '../../../components/rest/types'
|
||||
|
||||
export interface WebhookT {
|
||||
actions: string[]
|
||||
@@ -1,7 +1,7 @@
|
||||
import express from 'express'
|
||||
import { getWebhook } from '../../src/webhooks/lib/index.js'
|
||||
import { allVersions } from '../../lib/all-versions.js'
|
||||
import { defaultCacheControl } from '../cache-control.js'
|
||||
import { getWebhook } from '../lib/index.js'
|
||||
import { allVersions } from '../../../lib/all-versions.js'
|
||||
import { defaultCacheControl } from '../../../middleware/cache-control.js'
|
||||
|
||||
const router = express.Router()
|
||||
|
||||
115
src/webhooks/pages/webhook-events-and-payloads.tsx
Normal file
115
src/webhooks/pages/webhook-events-and-payloads.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
import { GetServerSideProps } from 'next'
|
||||
import { useRouter } from 'next/router'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
import { getMainContext, MainContext, MainContextT } from 'components/context/MainContext'
|
||||
import {
|
||||
getAutomatedPageContextFromRequest,
|
||||
AutomatedPageContext,
|
||||
AutomatedPageContextT,
|
||||
} from 'components/context/AutomatedPageContext'
|
||||
import { WebhookAction } from 'src/webhooks/components/types'
|
||||
import { Webhook } from 'src/webhooks/components/Webhook'
|
||||
import { AutomatedPage } from 'components/article/AutomatedPage'
|
||||
|
||||
type Props = {
|
||||
mainContext: MainContextT
|
||||
automatedPageContext: AutomatedPageContextT
|
||||
webhooks: WebhookAction[]
|
||||
}
|
||||
|
||||
export default function WebhooksEventsAndPayloads({
|
||||
mainContext,
|
||||
automatedPageContext,
|
||||
webhooks,
|
||||
}: Props) {
|
||||
const router = useRouter()
|
||||
const { locale } = router
|
||||
const content = webhooks.map((webhook: WebhookAction, index) => {
|
||||
return (
|
||||
<div key={`${webhook.data.requestPath}-${index}`}>
|
||||
<Webhook webhook={webhook} />
|
||||
</div>
|
||||
)
|
||||
})
|
||||
|
||||
// When someone clicks on a minitoc hash anchor link on this page, we want to
|
||||
// remove the type query parameter from the URL because the type won't make
|
||||
// sense anymore (e.g. ?actionTtype=closed#issues and you click on the fork minitoc
|
||||
// we don't want the URL to be ?actionType=closed#fork).
|
||||
useEffect(() => {
|
||||
const hashChangeHandler = () => {
|
||||
const { asPath } = router
|
||||
let [pathRoot, pathQuery = ''] = asPath.split('?')
|
||||
|
||||
if (pathRoot.includes('#')) {
|
||||
pathRoot = pathRoot.split('#')[0]
|
||||
}
|
||||
|
||||
// carry over any other query parameters besides `actionType` for the webhook
|
||||
// action type
|
||||
if (pathQuery.includes('#')) {
|
||||
pathQuery = pathQuery.split('#')[0]
|
||||
}
|
||||
const params = new URLSearchParams(pathQuery)
|
||||
params.delete('actionType')
|
||||
|
||||
if (location.hash) {
|
||||
router.replace(
|
||||
{ pathname: pathRoot, query: params.toString(), hash: location.hash },
|
||||
undefined,
|
||||
{
|
||||
shallow: true,
|
||||
locale,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener('hashchange', hashChangeHandler)
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('hashchange', hashChangeHandler)
|
||||
}
|
||||
}, [locale])
|
||||
|
||||
return (
|
||||
<MainContext.Provider value={mainContext}>
|
||||
<AutomatedPageContext.Provider value={automatedPageContext}>
|
||||
<AutomatedPage>{content}</AutomatedPage>
|
||||
</AutomatedPageContext.Provider>
|
||||
</MainContext.Provider>
|
||||
)
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
|
||||
const { getInitialPageWebhooks } = await import('src/webhooks/lib')
|
||||
const { getAutomatedPageMiniTocItems } = await import('lib/get-mini-toc-items')
|
||||
|
||||
const req = context.req as object
|
||||
const res = context.res as object
|
||||
const currentVersion = context.query.versionId as string
|
||||
const mainContext = await getMainContext(req, res)
|
||||
const { miniTocItems } = getAutomatedPageContextFromRequest(req)
|
||||
|
||||
// Get data for initial webhooks page (i.e. only 1 action type per webhook and
|
||||
// no nested parameters)
|
||||
const webhooks = (await getInitialPageWebhooks(currentVersion)) as WebhookAction[]
|
||||
|
||||
// Build the minitocs for the webhooks page which is based on the webhook
|
||||
// categories in addition to the Markdown in the webhook-events-and-payloads.md
|
||||
// content file
|
||||
const webhooksMiniTocs = await getAutomatedPageMiniTocItems(
|
||||
webhooks.map((webhook) => webhook.data.category),
|
||||
context
|
||||
)
|
||||
webhooksMiniTocs && miniTocItems.push(...webhooksMiniTocs)
|
||||
|
||||
return {
|
||||
props: {
|
||||
webhooks,
|
||||
mainContext,
|
||||
automatedPageContext: getAutomatedPageContextFromRequest(req),
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user