Skip to content

Repo sync

Repo sync #20

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 preview the changes.
# **Why we have it**: To help Docs contributors understand how to preview 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: '<!-- CODE_CHANGES_COMMENT -->'
# 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="<!-- CODE_CHANGES_COMMENT -->
## 🚀 Manual Deployment Required
It looks like this pull request contains code changes. To preview these changes, an internal Hubber will need to manually deploy the changes to one of our staging servers.
Thank you for your contribution!"
else
COMMENT_BODY="<!-- CODE_CHANGES_COMMENT -->
## 🚀 Manual Deployment Required
It looks like this pull request contains code changes. To preview these changes, you will need to deploy them manually.
Thank you for your contribution!"
fi
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY"