name: Code changes comment # **What it does**: When a PR is opened in docs-internal or docs containing code, it comments with instructions on how to deploy and review the changes. # **Why we have it**: To help Docs contributors understand how to review their changes. # **Who does it impact**: docs-internal and docs maintainers and contributors on: # Required in lieu of `pull_request` so that the comment can be posted to PRs opened from a fork. pull_request_target: types: - opened - synchronize # this applies to any non-content files, this workflow will run for all changed files unless it's ONLY these content-related changes paths-ignore: - 'content/**' - 'data/**' - 'assets/images/**' permissions: contents: read pull-requests: write # This allows a subsequently queued workflow run to interrupt previous runs concurrency: group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' cancel-in-progress: true jobs: postOnCodeChanges: if: ${{ github.event.pull_request.user.login != 'docs-bot' && (github.repository == 'github/docs-internal' || github.repository == 'github/docs') }} runs-on: ubuntu-latest env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: - name: check out repo content uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - name: Find code changes comment uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e id: findComment with: issue-number: ${{ github.event.pull_request.number }} comment-author: 'github-actions[bot]' body-includes: '' # TODO: We'll update this comment at a later time with permament-ish links to deployment instructions. - name: Comment on code changes if: ${{ !steps.findComment.outputs.comment-id }} run: | if [[ "${{ github.repository }}" == "github/docs" ]]; then COMMENT_BODY=" ### 👓 How to review these changes Thank you for your contribution. To review these changes, you can: 1. [Spin up a codespace](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/working-on-github-docs-in-a-codespace) 1. [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment) This pull request contains code changes, so we will not generate a table of review links. A Hubber will need to deploy your changes internally to review. 🤖 This comment is automatically generated." else COMMENT_BODY=" ### 👓 How to review these changes Thank you for your contribution. To review these changes, you can: 1. [Spin up a codespace](https://github.com/github/docs-team/blob/main/contributing-to-docs/use-a-codespace-to-review.md). 1. [Set up a local development environment](https://docs.github.com/en/contributing/setting-up-your-environment-to-work-on-github-docs/creating-a-local-environment#setting-up-your-local-environment). 1. Message \`#docs-engineering\` on Slack for a staging server. This pull request contains code changes, so we will not generate a table of review links. 🤖 This comment is automatically generated." fi gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY"