Repository navigation
Repo sync #508
This file contains hidden or 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
| name: Site policy sync | |
| # Keeps github/site-policy current with internal site policy docs. | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| types: | |
| - closed | |
| paths: | |
| - 'content/site-policy/**' | |
| - '.github/workflows/site-policy-sync.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| jobs: | |
| sync: | |
| name: Get the latest docs | |
| if: github.event_name == 'workflow_dispatch' || (github.event.pull_request.merged == true && github.repository == 'github/docs-internal') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: checkout docs-internal | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| - name: checkout public site-policy | |
| uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0 | |
| with: | |
| repository: github/site-policy | |
| token: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| fetch-depth: '' | |
| path: public-repo | |
| - name: Commits internal policies to copy of public repo with descriptive message from triggering PR title | |
| env: | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| run: | | |
| cd public-repo | |
| git config --local user.name 'site-policy-bot' | |
| git config --local user.email 'site-policy-bot@github.com' | |
| rm -rf Policies | |
| cp -r ../content/site-policy Policies | |
| git status | |
| git checkout -b automated-sync-$GITHUB_RUN_ID | |
| git add . | |
| echo PR_TITLE: $PR_TITLE | |
| [[ ! -z $PR_TITLE ]] && DESCRIPTION="${PR_TITLE}" || DESCRIPTION="Update manually triggered by workflow" | |
| echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_ENV | |
| # git commit exits 1 when the public repo already matches, which would fail the job. | |
| if git diff --cached --quiet; then | |
| echo "No updates to push to the public repo" | |
| echo "HAS_CHANGES=false" >> "$GITHUB_ENV" | |
| else | |
| git commit -m "$(echo $DESCRIPTION)" | |
| echo "HAS_CHANGES=true" >> "$GITHUB_ENV" | |
| fi | |
| - name: If there are changes to push, create a branch in the public repo and push changes | |
| if: env.HAS_CHANGES == 'true' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }} | |
| run: | | |
| cd public-repo | |
| git config --local user.name 'site-policy-bot' | |
| git config --local user.email 'site-policy-bot@github.com' | |
| git push --set-upstream origin automated-sync-$GITHUB_RUN_ID |