-
Notifications
You must be signed in to change notification settings - Fork 0
42 lines (38 loc) · 1.55 KB
/
sync-cli-help-to-user-docs.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Synchronize Help
on:
workflow_dispatch:
schedule:
- cron: '0 12 * * 1-5' # Mon-Fri at 12
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 "noreply@snyk.io"
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
npx prettier --write ./help/cli-commands
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="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 }}