Skip to content

Restored erroneously deleted quote + line break #12

Restored erroneously deleted quote + line break

Restored erroneously deleted quote + line break #12

on:
push:
branches: main
paths: "**/translate-en-messages.py"
jobs:
build:
if: (github.repository == 'adamlui/python-utils') && (github.event.commits[0].committer.username != 'kudo-sync-bot')
runs-on: ubuntu-latest
env:
TZ: PST8PDT
steps:
- name: Checkout adamlui/python-utils
uses: actions/checkout@v4
with:
token: ${{ secrets.REPO_SYNC_PAT }}
repository: adamlui/python-utils
path: adamlui/python-utils
fetch-depth: 2
- name: Build list of target repos
id: list_repos
run: |
target_repos=( \
"adamlui/userscripts" "adamlui/chatgpt-apps" "adamlui/js-utils" "adamlui/autoclear-chatgpt-history" \
"adamlui/chatgpt-auto-continue" "adamlui/chatgpt-auto-refresh" "adamlui/chatgpt-auto-talk" "adamlui/chatgpt-infinity" \
"adamlui/chatgpt-widescreen" "adamlui/minify.js" "adamlui/youtube-classic" "KudoAI/chatgpt.js" \
"KudoAI/amazongpt" "KudoAI/bravegpt" "KudoAI/duckduckgpt" "KudoAI/googlegpt")
echo "::set-output name=REPOS::${target_repos[*]}"
- name: Checkout target repos
run: |
target_repos=(${{ steps.list_repos.outputs.REPOS }})
for repo in "${target_repos[@]}"; do
repo_path="${repo//\//_}"
echo "::group::Checking out $repo"
git clone https://github.com/$repo.git $GITHUB_WORKSPACE/$repo_path
echo "::endgroup::"
done
- 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: Replace outdated files in target repos, push changes
run: |
target_repos=(${{ steps.list_repos.outputs.REPOS }})
source_file="${{ github.workspace }}/adamlui/python-utils/translate-messages/translate-en-messages.py"
source_timestamp=$(cd "${{ github.workspace }}/adamlui/python-utils" && git log -1 --format="%ct" -- "translate-messages/translate-en-messages.py")
for repo in "${target_repos[@]}"; do
echo "::group::Replacing translate-en-messages.py in $repo"
repo_path="${repo//\//_}"
target_dir="$GITHUB_WORKSPACE/$repo_path"
cd "$target_dir" || exit 1
target_files=$(find . -name "translate-en-messages.py" -type f)
for target_file in $target_files; do
target_timestamp=$(git log -1 --format="%ct" -- "$target_file")
if [[ $source_timestamp -gt $target_timestamp ]]; then
echo "Copying $source_file to $target_file"
cp -f "$source_file" "$target_file"
git add "$target_file"
fi
done
git diff-index --quiet HEAD || (echo "Committing changes" && \
git commit -m "$ESCAPED_MSG ↞ [auto-sync from https://github.com/adamlui/python-utils]")
git remote set-url --push origin "https://kudo-sync-bot:${{ secrets.REPO_SYNC_PAT }}@github.com/$repo"
echo "Pushing changes"
git push --force
echo "::endgroup::"
done