1
0
mirror of synced 2025-12-19 09:57:42 -05:00
Files
docs/.github/workflows/site-policy-sync.yml
dependabot[bot] 3e333183fb Bump actions/checkout from 5.0.0 to 6.0.1 (#58937)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-12-16 23:37:47 +00:00

71 lines
2.6 KiB
YAML

name: Site policy sync
# **What it does**: Creates a branch in our site-policy repo with changes to site policy docs.
# **Why we have it**: We want to keep the site-policy repo up to date.
# **Who does it impact**: site-policy-admins and Developer Policy teams.
# Controls when the action will run.
on:
# Triggers the workflow pull requests merged to the main branch
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@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
- name: checkout public site-policy
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
repository: github/site-policy
token: ${{ secrets.API_TOKEN_SITEPOLICY }}
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 -m "$(echo $DESCRIPTION)"
- name: If there are changes to push, create a branch in the public repo and push changes
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'
NUM_FILES_CHANGED=$(git diff --name-only HEAD^..HEAD | wc -l)
if [[ $NUM_FILES_CHANGED -ge 1 ]]
then
git push --set-upstream origin automated-sync-$GITHUB_RUN_ID
else
echo "No updates to push to the public repo"
fi