Skip to content

Added ghimirebibek to contributors (KudoAI/chatgpt.js#324) #152

Added ghimirebibek to contributors (KudoAI/chatgpt.js#324)

Added ghimirebibek to contributors (KudoAI/chatgpt.js#324) #152

name: Sync English READMEs between root + docs/
on:
push:
branches: [main]
paths:
- README.md
- docs/README.md
jobs:
build:
if: (github.repository == 'KudoAI/chatgpt.js') && (github.event.commits[0].committer.username != 'kudo-sync-bot')
runs-on: ubuntu-latest
env:
TZ: PST8PDT
steps:
- name: Checkout KudoAI/chatgpt.js
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: KudoAI/chatgpt.js
path: KudoAI/chatgpt.js
fetch-depth: 2
- name: Sync English READMEs between root + docs/
run: |
cd "${{ github.workspace }}/KudoAI/chatgpt.js"
root_readme_modified=$(git log -1 --format="%ct" -- "README.md")
docs_readme_modified=$(git log -1 --format="%ct" -- "docs/README.md")
if [ "$root_readme_modified" -gt "$docs_readme_modified" ] ; then cp -f "README.md" "docs/README.md" ; sync_src="root"
elif [ "$docs_readme_modified" -gt "$root_readme_modified" ] ; then cp -f "docs/README.md" "README.md" ; sync_src="docs" ; fi
# Expose sync src for commit msg in push step
echo "SYNC_SRC=$sync_src" >> $GITHUB_ENV
- name: Escape backticks in commit msg
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
run: |
echo "ESCAPED_MSG<<EOF" >> $GITHUB_ENV
echo "$COMMIT_MSG" | sed 's/`/\`/g' >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Config committer
run: |
gpg --batch --import <(echo "${{ secrets.GPG_PRIVATE_KEY }}")
git config --global commit.gpgsign true
git config --global user.name "kudo-sync-bot"
git config --global user.email "[email protected]"
git config --global user.signingkey "${{ secrets.GPG_PRIVATE_ID }}"
- name: Push changes to KudoAI/chatgpt.js
run: |
cd ${{ github.workspace }}/KudoAI/chatgpt.js
git add .
git commit -n -m "$ESCAPED_MSG ↞ [auto-sync from \`${{ env.SYNC_SRC }}\`]" || true
git push