Skip to content

synchronize

synchronize #991

Workflow file for this run

# Automatically add commits to fix pull requests. This workflow must initiate
# from an authenticated bot repo collaborator. Check for opt-out label.
# Webhook events: Pull requests
name: Auto-fix pull request
on:
repository_dispatch:
types: [opened, synchronize]
jobs:
nbfmt:
name: Fix notebook formatting
# Check for opt-out label.
if: >-
${{ github.actor == 'tfdocsbot' &&
!contains(github.event.client_payload.pull_request.labels.*.name, 'disable-autofix') }}
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Install tensorflow-docs
run: python3 -m pip install -U git+https://github.com/tensorflow/docs
- name: Fetch pull request branch
uses: actions/checkout@v2
with:
# Head repo is the user's fork. Ref is the branch name.
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
- name: Fetch base master branch
run: git fetch -u "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" master:master
- name: Format notebooks
run: |
git restore -s master -- ./tools/ci/utils.sh
source ./tools/ci/utils.sh
# Snapshot formatting already handled in sync script.
readarray -t changed_files < <(get_changed_files | grep '\.ipynb$' | grep -v 'en-snapshot')
if [[ ${#changed_files[@]} == 0 ]]; then
echo "No notebooks modified in this pull request."
exit 0
fi
python3 -m tensorflow_docs.tools.nbfmt "${changed_files[@]}"
# If changes, push to the forked PR branch submitted by head.
push_commit "nbfmt"
nblint-fix:
name: Fix lint warnings
# Check for opt-out label.
if: >-
${{ github.actor == 'tfdocsbot' &&
!contains(github.event.client_payload.pull_request.labels.*.name, 'disable-autofix') }}
runs-on: ubuntu-latest
steps:
- name: Set up Python
uses: actions/setup-python@v2
- name: Install tensorflow-docs
run: python3 -m pip install -U git+https://github.com/tensorflow/docs
- name: Fetch pull request branch
uses: actions/checkout@v2
with:
# Head repo is the user's fork. Ref is the branch name.
repository: ${{ github.event.client_payload.pull_request.head.repo.full_name }}
ref: ${{ github.event.client_payload.pull_request.head.sha }}
- name: Fetch base master branch
run: git fetch -u "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" master:master
- name: Fix lint warnings in notebooks
run: |
git restore -s master -- ./tools/ci/utils.sh
source ./tools/ci/utils.sh
readarray -t changed_files < <(get_changed_files | grep '\.ipynb$' | grep -v 'en-snapshot')
if [[ ${#changed_files[@]} == 0 ]]; then
echo "No notebooks modified in this pull request."
exit 0
fi
python3 -m tensorflow_docs.tools.nblint --fix --verbose \
--styles=tensorflow,tensorflow_docs_l10n \
--arg=repo:tensorflow/docs-l10n \
"${changed_files[@]}"
# If changes, push to the forked PR branch submitted by head.
push_commit "nblint fix"