diff --git a/.github/workflows/site-policy-sync.yml b/.github/workflows/site-policy-sync.yml index 7d88c6a5f1..fdf9afcdf6 100644 --- a/.github/workflows/site-policy-sync.yml +++ b/.github/workflows/site-policy-sync.yml @@ -1,7 +1,7 @@ name: Site policy sync -# **What it does**: Updates our site-policy repo when changes happen to site policy docs. -# **Why we have it**: We want keep site-policy repo up to date. +# **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. @@ -53,24 +53,17 @@ jobs: echo "DESCRIPTION=$DESCRIPTION" >> $GITHUB_ENV git commit -m "$(echo $DESCRIPTION)" - - name: If there are changes to push, create a pull request in the public repo using the gh command line tool, then immediately approve the PR - id: createAndMergePullRequest + - name: If there are changes to push, create a branch in the public repo and push changes env: - GITHUB_TOKEN: ${{ secrets.API_TOKEN_SITEPOLICY }} + GITHUB_TOKEN: ${{ secrets.DOCUBOT_REPO_PAT }} run: | cd public-repo git config --local user.name 'site-policy-bot' git config --local user.email 'site-policy-bot@github.com' - DIFF=$(git diff --name-status --summary HEAD^..HEAD) NUM_FILES_CHANGED=$(git diff --name-only HEAD^..HEAD | wc -l) - [[ $NUM_FILES_CHANGED -ge 2 ]] && TITLE="Sync changes from GitHub Docs" || TITLE=$(echo $DIFF | sed -e 's/^A\s/Added /g;s/^D\s/Deleted /g;s/^C\s/Copied /g;s/^M\s/Modified /g;s/^R100\s/Renamed /g;') - if [[ ! -z $TITLE ]] + if [[ $NUM_FILES_CHANGED -ge 1]] then - echo -e "This is an automated pull request to sync changes from GitHub Docs.\n\nDiff summary:\n\n${DIFF}" > msg git push --set-upstream origin automated-sync-$GITHUB_RUN_ID - PR_URL=$(gh pr create --title "${TITLE}" --body-file msg --head automated-sync-$GITHUB_RUN_ID --base main --repo github/site-policy) - gh pr diff ${PR_URL} - gh pr review --approve || echo "Nothing to approve" else echo "No updates to push to the public repo" fi