Skip to content

Commit 9715d92

Browse files
authored
Merge pull request #22015 from github/repo-sync
repo sync
2 parents c809aba + fdc4466 commit 9715d92

File tree

11 files changed

+57
-52
lines changed

11 files changed

+57
-52
lines changed
115 KB
Loading
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
title: Approving workflow runs from private forks
3+
intro: 'When someone without write access submits a pull request to a private repository, a maintainer may need to approve any workflow runs.'
4+
permissions: 'Maintainers with write access to a repository can approve workflow runs.'
5+
versions:
6+
feature: actions-private-fork-workflow-approvals
7+
shortTitle: Approve private fork runs
8+
---
9+
10+
## About workflow runs from private forks
11+
12+
{% data reusables.actions.private-repository-forks-overview %} For more information, see "[Enforcing a policy for fork pull requests in private repositories](/admin/policies/enforcing-policies-for-your-enterprise/enforcing-policies-for-github-actions-in-your-enterprise#enforcing-a-policy-for-fork-pull-requests-in-private-repositories)."
13+
14+
## Approving workflow runs on a pull request from a private fork
15+
16+
{% data reusables.actions.workflows.approve-workflow-runs %}

content/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,4 @@ Workflow runs that have been awaiting approval for more than 30 days are automat
1717

1818
## Approving workflow runs on a pull request from a public fork
1919

20-
Maintainers with write access to a repository can use the following procedure to review and run workflows on pull requests from contributors that require approval.
21-
22-
{% data reusables.repositories.sidebar-pr %}
23-
{% data reusables.repositories.choose-pr-review %}
24-
{% data reusables.repositories.changed-files %}
25-
1. Inspect the proposed changes in the pull request and ensure that you are comfortable running your workflows on the pull request branch. You should be especially alert to any proposed changes in the `.github/workflows/` directory that affect workflow files.
26-
1. If you are comfortable with running workflows on the pull request branch, return to the {% octicon "comment-discussion" aria-label="The discussion icon" %} **Conversation** tab, and under "Workflow(s) awaiting approval", click **Approve and run**.
27-
28-
![Approve and run workflows](/assets/images/help/pull_requests/actions-approve-and-run-workflows-from-fork.png)
20+
{% data reusables.actions.workflows.approve-workflow-runs %}

content/actions/managing-workflow-runs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ children:
1818
- /re-running-workflows-and-jobs
1919
- /canceling-a-workflow
2020
- /approving-workflow-runs-from-public-forks
21+
- /approving-workflow-runs-from-private-forks
2122
- /reviewing-deployments
2223
- /disabling-and-enabling-a-workflow
2324
- /skipping-workflow-runs
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: #8433
2+
# Allow admins to require approval on fork PR in private repos
3+
versions:
4+
fpt: '*'
5+
ghec: '*'
6+
ghes: '>= 3.8'
7+
ghae: '>= 3.8'
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
1. Under **Fork pull request workflows**, select your options. For example:
2-
![Enable, disable, or limits actions for this repository](/assets/images/help/settings/actions-fork-pull-request-workflows.png)
2+
{% ifversion actions-private-fork-workflow-approvals %}
3+
![Enable, disable, or limits actions for this repository](/assets/images/help/settings/actions-fork-pull-request-workflows-require-approval.png){% else %}
4+
5+
![Enable, disable, or limits actions for this repository](/assets/images/help/settings/actions-fork-pull-request-workflows.png){% endif %}
6+
37
1. Click **Save** to apply the settings.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
- **Run workflows from fork pull requests** - Allows users to run workflows from fork pull requests, using a `GITHUB_TOKEN` with read-only permission, and with no access to secrets.
22
- **Send write tokens to workflows from pull requests** - Allows pull requests from forks to use a `GITHUB_TOKEN` with write permission.
3-
- **Send secrets to workflows from pull requests** - Makes all secrets available to the pull request.
3+
- **Send secrets to workflows from pull requests** - Makes all secrets available to the pull request.{% ifversion actions-private-fork-workflow-approvals %}
4+
- **Require approval for fork pull request workflows** - Workflow runs on pull requests from collaborators without write permission will require approval from someone with write permission before they will run.{% endif %}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Maintainers with write access to a repository can use the following procedure to review and run workflows on pull requests from contributors that require approval.
2+
3+
{% data reusables.repositories.sidebar-pr %}
4+
{% data reusables.repositories.choose-pr-review %}
5+
{% data reusables.repositories.changed-files %}
6+
1. Inspect the proposed changes in the pull request and ensure that you are comfortable running your workflows on the pull request branch. You should be especially alert to any proposed changes in the `.github/workflows/` directory that affect workflow files.
7+
1. If you are comfortable with running workflows on the pull request branch, return to the {% octicon "comment-discussion" aria-label="The discussion icon" %} **Conversation** tab, and under "Workflow(s) awaiting approval", click **Approve and run**.
8+
9+
![Approve and run workflows](/assets/images/help/pull_requests/actions-approve-and-run-workflows-from-fork.png)

lib/rest/index.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,13 +65,6 @@ export default async function getRest(version, category, subCategory) {
6565
}
6666
}
6767

68-
function getDocsVersion(openApiVersion) {
69-
const version = Object.values(allVersions).find(
70-
(version) => version.openApiVersionName === openApiVersion
71-
).version
72-
return version
73-
}
74-
7568
function getOpenApiVersion(version) {
7669
if (!(version in allVersions)) {
7770
throw new Error(`Unrecognized version '${version}'. Not found in ${Object.keys(allVersions)}`)
@@ -104,14 +97,16 @@ export async function getRestMiniTocItems(
10497
return restOperationData.get(language).get(version).get(category).get(subCategory)
10598
}
10699

107-
export async function getEnabledForApps() {
108-
// The `readCompressedJsonFileFallback()` function
109-
// will check for both a .br and .json extension.
110-
const appsData = readCompressedJsonFileFallback(ENABLED_APPS_FILENAME)
111-
for (const version in appsData) {
112-
const docsVersion = getDocsVersion(version)
113-
appsData[docsVersion] = appsData[version]
114-
delete appsData[version]
100+
const enabledForApps = {}
101+
export async function getEnabledForApps(docsVersion) {
102+
if (Object.keys(enabledForApps).length === 0) {
103+
// The `readCompressedJsonFileFallback()` function
104+
// will check for both a .br and .json extension.
105+
Object.assign(enabledForApps, readCompressedJsonFileFallback(ENABLED_APPS_FILENAME))
106+
107+
// One off edge case where secret-scanning should be removed from FPT. Docs Content #6637
108+
delete enabledForApps['api.github.com']['secret-scanning']
115109
}
116-
return appsData
110+
const openApiVersion = getOpenApiVersion(docsVersion)
111+
return enabledForApps[openApiVersion]
117112
}

pages/[versionId]/rest/overview/endpoints-available-for-github-apps.tsx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ type EnabledAppCategoryT = {
2323
[category: string]: OperationT[]
2424
}
2525

26-
type AppDataT = {
27-
[version: string]: EnabledAppCategoryT
28-
}
29-
30-
let enabledForApps: AppDataT | null = null
31-
3226
type Props = {
3327
mainContext: MainContextT
3428
currentVersion: string
@@ -91,25 +85,17 @@ export default function Category({
9185
export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
9286
const req = context.req as object
9387
const res = context.res as object
94-
const currentVersion = context.query.versionId as string
9588
const mainContext = await getMainContext(req, res)
9689
const automatedPageContext = getAutomatedPageContextFromRequest(req)
90+
const currentVersion = context.query.versionId as string
9791

98-
if (!enabledForApps) {
99-
enabledForApps = (await getEnabledForApps()) as AppDataT
100-
}
101-
102-
// One off edge case where secret-scanning should be removed from FPT. Docs Content #6637
103-
const noSecretScanning = { ...enabledForApps[currentVersion] }
104-
delete noSecretScanning['secret-scanning']
105-
const overrideEnabledForApps =
106-
currentVersion === 'free-pro-team@latest' ? noSecretScanning : enabledForApps[currentVersion]
92+
const enabledForApps = await getEnabledForApps(currentVersion)
10793

10894
return {
10995
props: {
11096
mainContext,
11197
currentVersion,
112-
enabledForApps: overrideEnabledForApps,
98+
enabledForApps,
11399
automatedPageContext,
114100
categoriesWithoutSubcategories,
115101
},

0 commit comments

Comments
 (0)