Synchronize Help #764
This file contains 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: Synchronize Help | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: '0 9 * * 1' # Mon at 9 | |
push: | |
branches: [chore/docs-action] | |
jobs: | |
build: | |
name: synchronize-help | |
runs-on: ubuntu-latest | |
steps: | |
- run: | | |
gh auth setup-git | |
git config --global user.email "[email protected]" | |
git config --global user.name "$GITHUB_ACTOR" | |
gh repo clone snyk/snyk cli -- --depth=1 --quiet | |
gh repo clone snyk/user-docs docs -- --depth=1 --quiet | |
git -C ./cli checkout -b docs/automatic-gitbook-update | |
cp ./docs/docs/snyk-cli/commands/*.md ./cli/help/cli-commands/ | |
if [[ $(git -C ./cli status --porcelain) ]]; then | |
echo "Documentation changes detected" | |
cd ./cli | |
npm clean-install | |
npx prettier --write ./help/cli-commands/*.md | |
git --no-pager diff --name-only | |
git add . | |
git commit -m "docs: synchronizing help from snyk/user-docs" | |
git push --force --set-upstream origin docs/automatic-gitbook-update | |
if [[ ! $(gh pr view docs/automatic-gitbook-update 2>&1 | grep -q "no open pull requests";) ]]; then | |
echo "Creating PR" | |
gh pr create --title="docs: Synchronizing CLI help from user-docs" --body="Automatic PR controlled by GitHub Action" --head docs/automatic-gitbook-update | |
fi | |
echo "PR exists, pushed changes to it." | |
else | |
echo "No documentation changes detected, exiting." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |