diff --git a/.github/actions-scripts/enable-automerge.js b/.github/actions-scripts/enable-automerge.js new file mode 100644 index 000000000000..1d3885a623b6 --- /dev/null +++ b/.github/actions-scripts/enable-automerge.js @@ -0,0 +1,39 @@ +import { getOctokit } from '@actions/github' +const token = process.env.GITHUB_TOKEN +const prNumber = process.env.AUTOMERGE_PR_NUMBER +const github = getOctokit(token) + +main() +async function main() { + const pull = await github.pulls.get({ + ...context.repo, + pull_number: parseInt(prNumber), + }) + + const pullNodeId = pull.data.node_id + console.log(`Pull request GraphQL Node ID: ${pullNodeId}`) + + const mutation = `mutation ($id: ID!) { + enablePullRequestAutoMerge(input: { + pullRequestId: $id, + mergeMethod: MERGE + }) { + clientMutationId + } + }` + const variables = { + id: pullNodeId, + } + + const graph = await github.graphql(mutation, variables) + console.log('GraphQL mutation result:\n' + JSON.stringify(graph)) + + if (graph.errors && graph.errors.length > 0) { + console.error( + 'ERROR! Failed to enable auto-merge:\n - ' + + graph.errors.map((error) => error.message).join('\n - ') + ) + } else { + console.log('Auto-merge enabled!') + } +} diff --git a/.github/allowed-actions.js b/.github/allowed-actions.js index e245095d90ed..210021ab139b 100644 --- a/.github/allowed-actions.js +++ b/.github/allowed-actions.js @@ -26,7 +26,6 @@ export default [ 'juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51', // v1.5.0 'juliangruber/read-file-action@e0a316da496006ffd19142f0fd594a1783f3b512', 'lee-dohm/no-response@9bb0a4b5e6a45046f00353d5de7d90fb8bd773bb', - 'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07', // v0.12.0 'peter-evans/create-issue-from-file@b4f9ee0a9d4abbfc6986601d9b1a4f8f8e74c77e', 'peter-evans/create-or-update-comment@5221bf4aa615e5c6e95bb142f9673a9c791be2cd', 'peter-evans/create-pull-request@7380612b49221684fefa025244f2ef4008ae50ad', // v3.10.1 diff --git a/.github/workflows/automerge.yml b/.github/workflows/automerge.yml deleted file mode 100644 index 1f85a981a373..000000000000 --- a/.github/workflows/automerge.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Automerge - -# **What it does**: Pull requests with label "automerge" or "autosquash" will automatically merge. -# **Why we have it**: While now this is a feature built into GitHub, we still use it as part of other automation. -# **Who does it impact**: Any workflows that depend on automerge or autosquash labels. - -on: - pull_request: - types: - - labeled - - unlabeled - - synchronize - - opened - - edited - - ready_for_review - - reopened - - unlocked - pull_request_review: - types: - - submitted - check_suite: - types: - - completed - status: {} -jobs: - automerge: - runs-on: ubuntu-latest - if: (contains(github.event.pull_request.labels.*.name, 'automerge') || contains(github.event.pull_request.labels.*.name, 'autosquash')) && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') - steps: - - name: automerge - uses: 'pascalgn/automerge-action@c9bd1823770819dc8fb8a5db2d11a3a95fbe9b07' - env: - GITHUB_TOKEN: '${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }}' - MERGE_METHOD_LABELS: 'automerge=merge,autosquash=squash' - MERGE_COMMIT_MESSAGE: 'pull-request-title' - MERGE_METHOD: 'merge' - MERGE_FORKS: 'true' - MERGE_RETRIES: '50' - MERGE_RETRY_SLEEP: '10000' # ten seconds - UPDATE_LABELS: 'automerge,autosquash' - UPDATE_METHOD: 'merge' - HUSKY: '0' # Disable pre-commit hooks diff --git a/.github/workflows/enterprise-dates.yml b/.github/workflows/enterprise-dates.yml index 283f74436b0b..6c14bb637388 100644 --- a/.github/workflows/enterprise-dates.yml +++ b/.github/workflows/enterprise-dates.yml @@ -64,10 +64,16 @@ jobs: "Hello! The GitHub Enterprise Server release dates have changed.\n\n If CI passes, this PR will be auto-merged. :green_heart:\n\n If CI does not pass or other problems arise, contact #docs-engineering on slack.\n\nThis PR was 🤖-crafted by `.github/workflows/enterprise-dates.yml`. 🧶" - labels: automerge,autoupdate + labels: autoupdate branch: enterprise-server-dates-update delete-branch: true + - name: Enable GitHub auto-merge + if: ${{ steps.create-pull-request.outputs.pull-request-number }} + env: + AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }} + run: node .github/actions-scripts/enable-automerge.js + - if: ${{ failure() && env.FREEZE != 'true' }} name: Delete remote branch (if previous steps failed) uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911 diff --git a/.github/workflows/repo-sync.yml b/.github/workflows/repo-sync.yml index 428666233912..51b199f7405a 100644 --- a/.github/workflows/repo-sync.yml +++ b/.github/workflows/repo-sync.yml @@ -216,38 +216,9 @@ jobs: - name: Enable GitHub auto-merge if: ${{ steps.find-pull-request.outputs.number }} - uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d - with: - github-token: ${{ secrets.OCTOMERGER_PAT_WITH_REPO_AND_WORKFLOW_SCOPE }} - script: | - const pull = await github.pulls.get({ - ...context.repo, - pull_number: parseInt(${{ steps.find-pull-request.outputs.number }}) - }) - - const pullNodeId = pull.data.node_id - console.log(`Pull request GraphQL Node ID: ${pullNodeId}`) - - const mutation = `mutation ($id: ID!) { - enablePullRequestAutoMerge(input: { - pullRequestId: $id, - mergeMethod: MERGE - }) { - clientMutationId - } - }` - const variables = { - id: pullNodeId - } - - const graph = await github.graphql(mutation, variables) - console.log('GraphQL mutation result:\n' + JSON.stringify(graph)) - - if (graph.errors && graph.errors.length > 0) { - console.error('ERROR! Failed to enable auto-merge:\n - ' + graph.errors.map(error => error.message).join('\n - ')) - } else { - console.log('Auto-merge enabled!') - } + env: + AUTOMERGE_PR_NUMBER: ${{ steps.find-pull-request.outputs.number }} + run: node .github/actions-scripts/enable-automerge.js - name: Send Slack notification if workflow fails uses: someimportantcompany/github-actions-slack-message@f8d28715e7b8a4717047d23f48c39827cacad340 diff --git a/.github/workflows/translations.yml b/.github/workflows/translations.yml deleted file mode 100644 index 62b26084d92e..000000000000 --- a/.github/workflows/translations.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: Translations - -# **What it does**: -# **Why we have it**: -# **Who does it impact**: Docs localization - -on: - schedule: - - cron: '20 19 * * *' # once a day at 19:20 UTC / 11:20 PST - -permissions: - pull-requests: write - -env: - FREEZE: ${{ secrets.FREEZE }} - -jobs: - prepare: - if: github.repository == 'github/docs-internal' - runs-on: ubuntu-latest - steps: - - if: ${{ env.FREEZE == 'true' }} - run: | - echo 'The repo is currently frozen! Exiting this workflow.' - exit 1 # prevents further steps from running - - name: Find original Pull Request - uses: juliangruber/find-pull-request-action@db875662766249c049b2dcd85293892d61cb0b51 - id: pr - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - branch: translations - base: main - author: octoglot - state: open - - if: ${{ steps.pr.outputs.number }} - name: Check if already labeled - uses: actions/github-script@2b34a689ec86a68d8ab9478298f91d5401337b7d - id: has-label - with: - script: | - const { data: labels } = await github.issues.listLabelsOnIssue({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: ${{ steps.pr.outputs.number }} - }) - if (labels.find(label => label.name === 'automerge')) { - return 'ok' - } - - if: ${{ !steps.has-label.outputs.result }} - name: Approve Pull Request - uses: juliangruber/approve-pull-request-action@c530832d4d346c597332e20e03605aa94fa150a8 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - number: ${{ steps.pr.outputs.number }} - - if: ${{ !steps.has-label.outputs.result }} - name: Add automerge label - uses: andymckay/labeler@e6c4322d0397f3240f0e7e30a33b5c5df2d39e90 - with: - issue-number: ${{ steps.pr.outputs.number }} - add-labels: 'automerge' diff --git a/.github/workflows/update-graphql-files.yml b/.github/workflows/update-graphql-files.yml index f12e2f8c53a4..6e938767d715 100644 --- a/.github/workflows/update-graphql-files.yml +++ b/.github/workflows/update-graphql-files.yml @@ -58,9 +58,15 @@ jobs: syncs up the GraphQL data in this repo.\n\n If CI passes, this PR will be auto-merged. :green_heart:\n\n If CI does not pass or other problems arise, contact #docs-engineering on slack." - labels: automerge,autoupdate + labels: autoupdate branch: graphql-schema-update + - name: Enable GitHub auto-merge + if: ${{ steps.create-pull-request.outputs.pull-request-number }} + env: + AUTOMERGE_PR_NUMBER: ${{ steps.create-pull-request.outputs.pull-request-number }} + run: node .github/actions-scripts/enable-automerge.js + - if: ${{ failure() && env.FREEZE != 'true'}} name: Delete remote branch (if previous steps failed) uses: dawidd6/action-delete-branch@47743101a121ad657031e6704086271ca81b1911 diff --git a/content/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md b/content/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md index 99a55d474bf8..b1ca69a0dc46 100644 --- a/content/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md +++ b/content/github/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax.md @@ -134,6 +134,18 @@ Here are some examples for using relative links to display an image. For more information, see "[Relative Links](#relative-links)." +{% ifversion fpt or ghec or ghes > 3.3 or ghae-issue-5559 %} +### Specifying the theme an image is shown to + +You can specify the theme an image is displayed to by appending `#gh-dark-mode-only` or `#gh-light-mode-only` to the end of an image URL, in Markdown. + +We distinguish between light and dark color modes, so there are two options available. You can use these options to display images optimized for dark or light backgrounds. This is particularly helpful for transparent PNG images. + +| Context | URL | +|--------|--------| +| Dark Theme | `![GitHub Light](https://github.com/github-light.png#gh-dark-mode-only)` | +| Light Theme | `![GitHub Dark](https://github.com/github-dark.png#gh-light-mode-only)` | +{% endif %} ## Lists