From 4d3fc0fd6a81840ae0715a034fb97c9a82815bbd Mon Sep 17 00:00:00 2001 From: Dmitry <1319595+flowmitry@users.noreply.github.com> Date: Tue, 19 Aug 2025 09:47:46 -0700 Subject: [PATCH 1/2] feat: add GitHub Actions workflow for SyncAI updates --- .github/workflows/syncai.yml | 92 ++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 .github/workflows/syncai.yml diff --git a/.github/workflows/syncai.yml b/.github/workflows/syncai.yml new file mode 100644 index 0000000..0fdf79a --- /dev/null +++ b/.github/workflows/syncai.yml @@ -0,0 +1,92 @@ +name: SyncAI + +on: + push: + # Ignore pushes to main and any release/* branches + branches-ignore: + - main + - 'release/*' + +permissions: + contents: write # needed for pushing changes back + +jobs: + update: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Install prerequisites + run: | + sudo apt-get update + sudo apt-get install -y jq + + - name: Get latest release tag + id: get_latest + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + const latest = await github.rest.repos.getLatestRelease({ + owner: 'flowmitry', + repo: 'syncai' + }); + return latest.data.tag_name; + + - name: Cache syncai binary + id: cache + uses: actions/cache@v3 + with: + path: ${{ runner.temp }}/syncai-cache + key: syncai-binary-${{ runner.os }}-${{ steps.get_latest.outputs.result }} + restore-keys: | + syncai-binary-${{ runner.os }}- + + - name: Download syncai binary + if: steps.cache.outputs.cache-hit != 'true' + run: | + mkdir -p ${{ runner.temp }}/syncai-cache + # Determine OS + UNAME=$(uname -s) + case "$UNAME" in + Linux) OS=linux;; + Darwin) OS=darwin;; + *) echo "Unsupported OS: $UNAME"; exit 1;; + esac + # Determine ARCH + ARCH_RAW=$(uname -m) + case "$ARCH_RAW" in + x86_64) ARCH=amd64;; + aarch64|arm64) ARCH=arm64;; + *) echo "Unsupported ARCH: $ARCH_RAW"; exit 1;; + esac + NAME="syncai_${OS}_${ARCH}" + echo "Looking for asset: $NAME" + # Fetch download URL matching exact asset name + ASSET_URL=$(curl -s https://api.github.com/repos/flowmitry/syncai/releases/latest | jq -r ".assets[] | select(.name==\"$NAME\") | .browser_download_url") + if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then + echo "Error: Could not find asset $NAME in latest release" + exit 1 + fi + echo "Downloading from: $ASSET_URL" + curl -sL "$ASSET_URL" -o ${{ runner.temp }}/syncai-cache/syncai + chmod +x ${{ runner.temp }}/syncai-cache/syncai + + - name: Run syncai + run: | + BINARY_PATH="${{ runner.temp }}/syncai-cache/syncai" + "$BINARY_PATH" --no-watch --config "${{ github.workspace }}/syncai.json" + + - name: Commit changes if any + run: | + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + if [[ -n $(git status --porcelain) ]]; then + git add . + git commit -m "syncai: apply updates" + git push + fi From a27e3da0532c758bda799925b7768b66494dc346 Mon Sep 17 00:00:00 2001 From: Dmitry <1319595+flowmitry@users.noreply.github.com> Date: Tue, 19 Aug 2025 09:52:10 -0700 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .github/workflows/syncai.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/syncai.yml b/.github/workflows/syncai.yml index 0fdf79a..76c2a60 100644 --- a/.github/workflows/syncai.yml +++ b/.github/workflows/syncai.yml @@ -39,7 +39,7 @@ jobs: - name: Cache syncai binary id: cache - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: ${{ runner.temp }}/syncai-cache key: syncai-binary-${{ runner.os }}-${{ steps.get_latest.outputs.result }} @@ -67,7 +67,7 @@ jobs: NAME="syncai_${OS}_${ARCH}" echo "Looking for asset: $NAME" # Fetch download URL matching exact asset name - ASSET_URL=$(curl -s https://api.github.com/repos/flowmitry/syncai/releases/latest | jq -r ".assets[] | select(.name==\"$NAME\") | .browser_download_url") + ASSET_URL=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/flowmitry/syncai/releases/latest | jq -r ".assets[] | select(.name==\"$NAME\") | .browser_download_url") if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then echo "Error: Could not find asset $NAME in latest release" exit 1 @@ -79,7 +79,12 @@ jobs: - name: Run syncai run: | BINARY_PATH="${{ runner.temp }}/syncai-cache/syncai" - "$BINARY_PATH" --no-watch --config "${{ github.workspace }}/syncai.json" + CONFIG_PATH="${{ github.workspace }}/syncai.json" + if [ ! -f "$CONFIG_PATH" ]; then + echo "Error: Configuration file $CONFIG_PATH not found." + exit 1 + fi + "$BINARY_PATH" --no-watch --config "$CONFIG_PATH" - name: Commit changes if any run: |