Skip to content

Bumped version

Bumped version #3

on:
push:
branches: main
paths: "**/translate-en-messages.py"
permissions:
contents: read
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/ai-web-extensions"
"adamlui/autoclear-chatgpt-history"
"adamlui/brave-omnibox"
"adamlui/chatgpt-auto-continue"
"adamlui/chatgpt-auto-refresh"
"adamlui/chatgpt-auto-talk"
"adamlui/chatgpt-infinity"
"adamlui/chatgpt-omnibox"
"adamlui/chatgpt-widescreen"
"adamlui/deepseek-omnibox"
"adamlui/js-utils"
"adamlui/minify.js"
"adamlui/perplexity-omnibox"
"adamlui/phind-omnibox"
"adamlui/userscripts"
"adamlui/you.com-omnibox"
"adamlui/youtube-classic"
"KudoAI/amazongpt"
"KudoAI/bravegpt"
"KudoAI/chatgpt.js"
"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/tree/main/translate-messages]")
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