Skip to content

Commit

Permalink
fix: readme sync (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelkaporin authored Aug 15, 2022
1 parent f8a1675 commit 9bc9ae9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/readme-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
git config --global user.name "$GITHUB_ACTOR"
gh repo clone snyk/$DESTINATION_REPOSITORY $DESTINATION_REPOSITORY -- --depth=1 --quiet
gh repo clone snyk/user-docs docs -- --depth=1 --quiet
git -C ./$DESTINATION_REPOSITORY checkout -b $DESTINATION_BRANCH
git -C ./$DESTINATION_REPOSITORY checkout -B $DESTINATION_BRANCH
cp $SOURCE_PATH ./$DESTINATION_REPOSITORY/$FILE_TO_COMMIT
sed -i \
-e "s|../.gitbook/assets/|https://github.com/snyk/user-docs/raw/HEAD/docs/.gitbook/assets/|g" \
-e "s|../../.gitbook/assets/|https://github.com/snyk/user-docs/raw/HEAD/docs/.gitbook/assets/|g" \
./$DESTINATION_REPOSITORY/$FILE_TO_COMMIT
sed -i \
-E "s|\!\\[([[:alnum:][:space:][:punct:]]*)\]\(<([[:alnum:][:punct:]\-\.\/:[:space:]\(\)]+)>\)|<img src=\"\2\" alt=\"\1\" />|g" \
Expand All @@ -32,6 +32,7 @@ jobs:
if [[ $(git -C ./$DESTINATION_REPOSITORY status --porcelain) ]]; then
echo "Documentation changes detected"
cd ./$DESTINATION_REPOSITORY
git push -f -u origin $DESTINATION_BRANCH
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
export CONTENT=$( base64 -i $FILE_TO_COMMIT )
Expand All @@ -42,7 +43,7 @@ jobs:
--field branch="$DESTINATION_BRANCH" \
--field sha="$SHA"
if [[ ! $(gh pr view $DESTINATION_BRANCH 2>&1 | grep -q "no open pull requests";) ]]; then
if [[ ! $(gh pr list --search "$MESSAGE" 2>&1 | grep -e "$MESSAGE";) ]]; then
echo "Creating PR"
gh pr create --title="$MESSAGE" --body="Automatic PR controlled by GitHub Action." --head $DESTINATION_BRANCH
fi
Expand All @@ -51,9 +52,9 @@ jobs:
echo "No documentation changes detected, exiting."
fi
env:
SOURCE_PATH: ./docs/docs/ide-tools/visual-studio-extension.md
SOURCE_PATH: ./docs/docs/ide-tools/visual-studio-extension/README.md
FILE_TO_COMMIT: README.md
DESTINATION_REPOSITORY: snyk-visual-studio-plugin
DESTINATION_BRANCH: docs/automatic-gitbook-update
MESSAGE: 'docs: synchronizing README from snyk/user-docs'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 9bc9ae9

Please sign in to comment.