forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request github#31541 from github/repo-sync
Repo sync
- Loading branch information
Showing
10 changed files
with
129 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,16 @@ on: | |
workflow_dispatch: | ||
schedule: | ||
- cron: '20 16 * * 1' # Run every Monday at 16:20 UTC / 8:20 PST | ||
pull_request: | ||
paths: | ||
- .github/workflows/orphaned-assets-check.yml | ||
# In case any of the dependencies affect the script | ||
- 'package*.json' | ||
- src/assets/scripts/find-orphaned-assets.js | ||
- src/workflows/walk-files.js | ||
- src/languages/lib/languages.js | ||
- .github/actions/clone-translations/action.yml | ||
- .github/actions/node-npm-setup/action.yml | ||
|
||
permissions: | ||
contents: read | ||
|
@@ -38,6 +48,7 @@ jobs: | |
env: | ||
# Needed for gh | ||
GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_READPUBLICKEY }} | ||
DRY_RUN: ${{ github.event_name == 'pull_request'}} | ||
run: | | ||
set -e | ||
|
@@ -53,6 +64,13 @@ jobs: | |
# If nothing to commit, exit now. It's fine. No orphans. | ||
git status -- ':!translations*' | grep 'nothing to commit' && exit 0 | ||
# When run on a pull_request, we're just testing the tooling. | ||
# Exit before it actually pushes the possible changes. | ||
if [ "$DRY_RUN" = "true" ]; then | ||
echo "Dry-run mode when run in a pull request" | ||
exit 0 | ||
fi | ||
# Replicated from the translation pipeline PR-maker Action | ||
git config --global user.name "docs-bot" | ||
git config --global user.email "[email protected]" | ||
|
@@ -82,7 +100,7 @@ jobs: | |
--label docs-content-fr | ||
- uses: ./.github/actions/slack-alert | ||
if: ${{ failure() && github.event_name != 'workflow_dispatch' }} | ||
if: ${{ failure() && github.event_name == 'schedule' }} | ||
with: | ||
slack_channel_id: ${{ secrets.DOCS_ALERTS_SLACK_CHANNEL_ID }} | ||
slack_token: ${{ secrets.SLACK_DOCS_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* This function is meant to be used by the code that runs the linter, | ||
* but only within Actions workflows. That means, if it works, it | ||
* posts all the annotations as inline comments on the PR. | ||
* | ||
*/ | ||
|
||
export function printAnnotationResults(results, { skippableRules = [] } = {}) { | ||
for (const [file, flaws] of Object.entries(results)) { | ||
for (const flaw of flaws) { | ||
if (intersection(flaw.ruleNames, skippableRules)) { | ||
continue | ||
} | ||
|
||
let annotation = `::${flaw.severity === 'error' ? 'error' : 'warning'} ` | ||
const bits = [`file=${file}`] | ||
if (flaw.lineNumber) { | ||
bits.push(`line=${flaw.lineNumber}`) | ||
// Note: it's possible to use a endLine property | ||
// if you can "lump" together the same error description on | ||
// consecutive lines. | ||
// See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message | ||
} | ||
|
||
if (flaw.ruleDescription) { | ||
bits.push(`title=${flaw.ruleDescription}`) | ||
} | ||
|
||
annotation += `${bits.join(',')}` | ||
|
||
if (flaw.errorDetail) { | ||
annotation += `::${flaw.errorDetail}` | ||
} | ||
|
||
// Why console.log and not `core.error()` (from @actions/core)? | ||
// Because, this way you can debug this more easily on you own | ||
// terminal. | ||
console.log(annotation) | ||
} | ||
} | ||
} | ||
|
||
function intersection(arr1, arr2) { | ||
return arr1.some((item) => arr2.includes(item)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters