Skip to content

Commit

Permalink
Merge branch 'main' into add-octopus-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
saritai authored Jan 13, 2022
2 parents 45f6e0f + 41b6f26 commit 7ed26ea
Show file tree
Hide file tree
Showing 3,488 changed files with 88,803 additions and 94,205 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package-lock.json @github/docs-engineering
package.json @github/docs-engineering

# Localization
/.github/actions-scripts/create-translation-batch-pr.js @github/docs-localization
/.github/workflows/create-translation-batch-pr.yml @github/docs-localization
/.github/workflows/crowdin.yml @github/docs-localization
/crowdin*.yml @github/docs-engineering @github/docs-localization
Expand Down
142 changes: 142 additions & 0 deletions .github/actions-scripts/create-translation-batch-pr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
#!/usr/bin/env node

import fs from 'fs'
import github from '@actions/github'

const OPTIONS = Object.fromEntries(
['BASE', 'BODY_FILE', 'GITHUB_TOKEN', 'HEAD', 'LANGUAGE', 'TITLE', 'GITHUB_REPOSITORY'].map(
(envVarName) => {
const envVarValue = process.env[envVarName]
if (!envVarValue) {
throw new Error(`You must supply a ${envVarName} environment variable`)
}
return [envVarName, envVarValue]
}
)
)

if (!process.env.GITHUB_REPOSITORY) {
throw new Error('GITHUB_REPOSITORY environment variable not set')
}

const RETRY_STATUSES = [
422, // Retry the operation if the PR already exists
502, // Retry the operation if the API responds with a `502 Bad Gateway` error.
]
const RETRY_ATTEMPTS = 3
const {
// One of the default environment variables provided by Actions.
GITHUB_REPOSITORY,

// These are passed in from the step in the workflow file.
TITLE,
BASE,
HEAD,
LANGUAGE,
BODY_FILE,
GITHUB_TOKEN,
} = OPTIONS
const [OWNER, REPO] = GITHUB_REPOSITORY.split('/')

const octokit = github.getOctokit(GITHUB_TOKEN)

/**
* @param {object} config Configuration options for finding the PR.
* @returns {Promise<number | undefined>} The PR number.
*/
async function findPullRequestNumber(config) {
// Get a list of PRs and see if one already exists.
const { data: listOfPullRequests } = await octokit.rest.pulls.list({
owner: config.owner,
repo: config.repo,
head: `${config.owner}:${config.head}`,
})

return listOfPullRequests[0]?.number
}

/**
* When this file was first created, we only introduced support for creating a pull request for some translation batch.
* However, some of our first workflow runs failed during the pull request creation due to a timeout error.
* There have been cases where, despite the timeout error, the pull request gets created _anyway_.
* To accommodate this reality, we created this function to look for an existing pull request before a new one is created.
* Although the "find" check is redundant in the first "cycle", it's designed this way to recursively call the function again via its retry mechanism should that be necessary.
*
* @param {object} config Configuration options for creating the pull request.
* @returns {Promise<number>} The PR number.
*/
async function findOrCreatePullRequest(config) {
const found = await findPullRequestNumber(config)

if (found) {
return found
}

try {
const { data: pullRequest } = await octokit.rest.pulls.create({
owner: config.owner,
repo: config.repo,
base: config.base,
head: config.head,
title: config.title,
body: config.body,
draft: false,
})

return pullRequest.number
} catch (error) {
if (!error.response || !config.retryCount) {
throw error
}

if (!config.retryStatuses.includes(error.response.status)) {
throw error
}

console.error(`Error creating pull request: ${error.message}`)
console.warn(`Retrying in 5 seconds...`)
await new Promise((resolve) => setTimeout(resolve, 5000))

config.retryCount -= 1

return findOrCreatePullRequest(config)
}
}

/**
* @param {object} config Configuration options for labeling the PR
* @returns {Promise<undefined>}
*/
async function labelPullRequest(config) {
await octokit.rest.issues.update({
owner: config.owner,
repo: config.repo,
issue_number: config.issue_number,
labels: config.labels,
})
}

async function main() {
const options = {
title: TITLE,
base: BASE,
head: HEAD,
body: fs.readFileSync(BODY_FILE, 'utf8'),
labels: ['translation-batch', `translation-batch-${LANGUAGE}`],
owner: OWNER,
repo: REPO,
retryStatuses: RETRY_STATUSES,
retryCount: RETRY_ATTEMPTS,
}

options.issue_number = await findOrCreatePullRequest(options)
const pr = `${GITHUB_REPOSITORY}#${options.issue_number}`
console.log(`Created PR ${pr}`)

// metadata parameters aren't currently available in `github.rest.pulls.create`,
// but they are in `github.rest.issues.update`.
await labelPullRequest(options)
console.log(`Updated ${pr} with these labels: ${options.labels.join(', ')}`)
}

main()
25 changes: 13 additions & 12 deletions .github/workflows/create-translation-batch-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,26 +166,27 @@ jobs:
script/i18n/report-reset-files.js --report-type=csv --language=${{ matrix.language }} --log-file=/tmp/batch.log > $csvFile
git add -f $csvFile && git commit -m "Check in ${{ matrix.language }} CSV report" || echo "Nothing to commit"
- name: Write the reported files that were reset to /tmp/pr-body.txt
run: script/i18n/report-reset-files.js --report-type=pull-request-body --language=${{ matrix.language }} --log-file=/tmp/batch.log > /tmp/pr-body.txt

- name: Push filtered translations
run: git push origin ${{ steps.set-branch.outputs.BRANCH_NAME }}

- name: Close existing stale batches
uses: lee-dohm/close-matching-issues@e9e43aad2fa6f06a058cedfd8fb975fd93b56d8f
with:
token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}
query: 'type:pr label:translation-batch-${{ matrix.language }}'

- name: Create Pull Request
- name: Create translation batch pull request
env:
GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }}
# We'll try to create the pull request based on the changes we pushed up in the branch.
# If there are actually no differences between the branch and `main`, we'll delete it.
run: |
script/i18n/report-reset-files.js --report-type=pull-request-body --language=${{ matrix.language }} --log-file=/tmp/batch.log > /tmp/pr-body.txt
git push origin ${{ steps.set-branch.outputs.BRANCH_NAME }}
gh pr create --title "New translation batch for ${{ matrix.language }}" \
--base=main \
--head=${{ steps.set-branch.outputs.BRANCH_NAME }} \
--label "translation-batch-${{ matrix.language }}" \
--label "translation-batch" \
--body-file /tmp/pr-body.txt || git push origin :${{ steps.set-branch.outputs.BRANCH_NAME }}
TITLE: 'New translation batch for ${{ matrix.language }}'
BASE: 'main'
HEAD: ${{ steps.set-branch.outputs.BRANCH_NAME }}
LANGUAGE: ${{ matrix.language }}
BODY_FILE: '/tmp/pr-body.txt'
run: .github/actions-scripts/create-translation-batch-pr.js

- name: Approve PR
if: github.ref_name == 'main'
Expand Down
27 changes: 8 additions & 19 deletions .github/workflows/link-check-all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ concurrency:
cancel-in-progress: true

jobs:
build:
check-links:
runs-on: ${{ fromJSON('["ubuntu-latest", "self-hosted"]')[github.repository == 'github/docs-internal'] }}
steps:
- name: Checkout
Expand All @@ -37,26 +37,15 @@ jobs:
- name: Install
run: npm ci

# Creates file "${{ env.HOME }}/files.json", among others
- name: Gather files changed
uses: trilom/file-changes-action@a6ca26c14274c33b15e6499323aac178af06ad4b
id: get_diff_files

# Necessary because trilom/file-changes-action can't escape each file
# name for using in bash. So, we do it ourselves.
# trilom/file-changes-action will, by default produce outputs
# in JSON format. We consume that and set a new output where each
# filename is wrapped in quotation marks.
# Perhaps some day we can rely on this directly based on;
# https://github.com/trilom/file-changes-action/issues/130
- name: Escape each diff file name
id: get_diff_files_escaped
uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d
with:
github-token: ${{ secrets.DOCUBOT_READORG_REPO_WORKFLOW_SCOPES }}
script: |
const input = JSON.parse('${{ steps.get_diff_files.outputs.files }}')
const files = input.map(filename => `"${filename}"`)
core.setOutput('files', files.join(' '))
fileOutput: 'json'

# For verification
- name: Show files changed
run: cat $HOME/files.json

- name: Link check (warnings, changed files)
run: |
Expand All @@ -66,7 +55,7 @@ jobs:
--check-anchors \
--check-images \
--verbose \
${{ steps.get_diff_files_escaped.outputs.files }}
--list $HOME/files.json
- name: Link check (critical, all files)
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/staging-build-and-deploy-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
run: node script/early-access/clone-for-build.js
env:
DOCUBOT_REPO_PAT: ${{ secrets.DOCUBOT_REPO_PAT }}
GIT_BRANCH: ${{ github.event.pull_request.head.sha }}
GIT_BRANCH: ${{ github.head_ref || github.ref }}

- name: Create a Heroku build source
id: build-source
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"files.exclude": {
"**/translations": true
}
},
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false
}
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ See [the contributing guide](CONTRIBUTING.md) for detailed instructions on how t

We accept different [types of contributions](https://github.com/github/docs/blob/main/contributing/types-of-contributions.md), including some that don't require you to write a single line of code.

On the GitHub Docs site, you can click the make a contribution button to open a PR(Pull Request) for quick fixes like typos, updates, or link fixes.
On the GitHub Docs site, you can click the make a contribution button to open a pull request for quick fixes like typos, updates, or link fixes.

<img src="./assets/images/contribution_cta.png" width="400">

For more complex contributions, you can open an issue using the most appropriate [issue template](https://github.com/github/docs/issues/new/choose) to describe the changes you'd like to see. By this way you can also be a part of Open source contributor's community without even writing a single line of code.
For more complex contributions, you can open an issue using the most appropriate [issue template](https://github.com/github/docs/issues/new/choose) to describe the changes you'd like to see.

If you're looking for a way to contribute, you can scan through our [existing issues](https://github.com/github/docs/issues) for something to work on. When ready, check out [Getting Started with Contributing](/CONTRIBUTING.md) for detailed instructions.

Expand All @@ -33,7 +33,6 @@ That's how you can easily become a member of the GitHub Documentation community.
## READMEs

In addition to the README you're reading right now, this repo includes other READMEs that describe the purpose of each subdirectory in more detail:
You can go through among them for specified details regarding the topics listed below.

- [content/README.md](content/README.md)
- [content/graphql/README.md](content/graphql/README.md)
Expand All @@ -57,7 +56,7 @@ The GitHub product documentation in the assets, content, and data folders are li

All other code in this repository is licensed under the [MIT license](LICENSE-CODE).

When you are using the GitHub logos, be sure to follow the [GitHub logo guidelines](https://github.com/logos).
When using the GitHub logos, be sure to follow the [GitHub logo guidelines](https://github.com/logos).

## Thanks :purple_heart:

Expand Down
Binary file removed assets/images/help/classroom/autograding-hero.png
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/images/help/writing/markdown-toolbar.gif
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ To help you understand your subscriptions and decide whether to unsubscribe, see

## Choosing how to unsubscribe

To unwatch (or unsubscribe from) repositories quickly, go to the "Watched repositories" page, where you can see all repositories you're watching. For more information, see "[Unwatch a repository](#unwatch-a-repository)."
To unwatch (or unsubscribe from) repositories quickly, navigate to [github.com/watching](https://github.com/watching) to see all the repositories you're following. For more information, see "[Unwatching repositories](#unwatching-repositories)."

To unsubscribe from multiple notifications at the same time, you can unsubscribe using your inbox or on the subscriptions page. Both of these options offer more context about your subscriptions than the "Watched repositories" page.

Expand Down Expand Up @@ -57,20 +57,32 @@ When you unsubscribe from notifications in your inbox, they will automatically d
2. Select the notifications you want to unsubscribe to. In the top right, click **Unsubscribe.**
![Subscriptions page](/assets/images/help/notifications-v2/unsubscribe-from-subscriptions-page.png)

## Unwatch a repository
## Unwatching repositories

When you unwatch a repository, you unsubscribe from future updates from that repository unless you participate in a conversation or are @mentioned.

{% data reusables.notifications.access_notifications %}
1. In the left sidebar, under the list of repositories, use the "Manage notifications" drop-down to click **Watched repositories**.

![Manage notifications drop down menu options](/assets/images/help/notifications-v2/manage-notifications-options.png)

2. On the watched repositories page, after you've evaluated the repositories you're watching, choose whether to:
{% ifversion fpt or ghes > 3.0 or ghae or ghec %}
- Unwatch a repository
- Ignore all notifications for a repository
- Customize the types of event you receive notifications for ({% data reusables.notifications-v2.custom-notification-types %}, if enabled)
{% else %}
- Unwatch a repository
- Only watch releases for a repository
- Ignore all notifications for a repository
{% endif %}
{%- ifversion fpt or ghes > 3.0 or ghae or ghec %}
- Unwatch a repository
- Ignore all notifications for a repository
- If enabled, customize the types of event you receive notifications for ({% data reusables.notifications-v2.custom-notification-types %})
{%- else %}
- Unwatch a repository
- Only watch releases for a repository
- Ignore all notifications for a repository
{%- endif %}
{%- ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5819 %}
1. Optionally, to unsubscribe from all repositories owned by a given user or organization, select the **Unwatch all** dropdown and click the organization whose repositories you'd like to unsubscribe from. The button to unwatch all repositories is only available if you are watching all activity or custom notifications on over 10 repositories.

![Screenshot of the Unwatch All button.](/assets/images/help/notifications-v2/unsubscribe-from-all-repos.png)

- Click **Unwatch** to confirm that you want to unwatch the repositories owned by the selected user or organization, or click **Cancel** to cancel.

![Screenshot of the unwatch all confirmation dialogue.](/assets/images/help/notifications-v2/unwatch-repo-dialog.png)

{% endif %}
16 changes: 8 additions & 8 deletions content/actions/learn-github-actions/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,11 @@ Returns `true` if `search` contains `item`. If `search` is an array, this functi

#### Example using an array

`contains(github.event.issue.labels.*.name, 'bug')`
`contains(github.event.issue.labels.*.name, 'bug')` returns whether the issue related to the event has a label "bug".

#### Example using a string

`contains('Hello world', 'llo')` returns `true`
`contains('Hello world', 'llo')` returns `true`.

### startsWith

Expand All @@ -139,7 +139,7 @@ Returns `true` when `searchString` starts with `searchValue`. This function is n

#### Example

`startsWith('Hello world', 'He')` returns `true`
`startsWith('Hello world', 'He')` returns `true`.

### endsWith

Expand All @@ -149,7 +149,7 @@ Returns `true` if `searchString` ends with `searchValue`. This function is not c

#### Example

`endsWith('Hello world', 'ld')` returns `true`
`endsWith('Hello world', 'ld')` returns `true`.

### format

Expand All @@ -159,20 +159,20 @@ Replaces values in the `string`, with the variable `replaceValueN`. Variables in

#### Example

Returns 'Hello Mona the Octocat'

`format('Hello {0} {1} {2}', 'Mona', 'the', 'Octocat')`

#### Example escaping braces
Returns 'Hello Mona the Octocat'.

Returns '{Hello Mona the Octocat!}'
#### Example escaping braces

{% raw %}
```js
format('{{Hello {0} {1} {2}!}}', 'Mona', 'the', 'Octocat')
```
{% endraw %}

Returns '{Hello Mona the Octocat!}'.

### join

`join( array, optionalSeparator )`
Expand Down
Loading

0 comments on commit 7ed26ea

Please sign in to comment.