Skip to content

Commit 8a2e2e0

Browse files
committed
ci(auto-sync): fix downstream trigger by pinning repo and adding workflow to main
The 'Trigger downstream image build' step in auto-sync-upstream.yml was failing with 404 because: 1. After 'git remote add upstream ...', gh CLI auto-detected the upstream remote as the canonical repository and hit router-for-me/CLIProxyAPI's API instead of this fork. Pin the target explicitly with --repo "${{ github.repository }}". 2. workflow_dispatch requires the workflow file to live on the default branch. ghcr-remote-fix.yml only existed on the remote-fix branch, so the API could never resolve it. Add a copy on main.
1 parent bf427cd commit 8a2e2e0

2 files changed

Lines changed: 61 additions & 1 deletion

File tree

.github/workflows/auto-sync-upstream.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ jobs:
109109
if: steps.merge.outputs.clean == 'true' && steps.build.outputs.ok == 'true'
110110
env:
111111
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112-
run: gh workflow run ghcr-remote-fix.yml --ref "${TARGET_BRANCH}"
112+
run: gh workflow run ghcr-remote-fix.yml --repo "${{ github.repository }}" --ref "${TARGET_BRANCH}"
113113

114114
- name: Prepare PR branch (build failure case)
115115
if: steps.merge.outputs.clean == 'true' && steps.build.outputs.ok != 'true'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: ghcr-remote-fix
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- remote-fix
8+
9+
env:
10+
IMAGE: ghcr.io/${{ github.repository_owner }}/cli-proxy-api-plus
11+
12+
jobs:
13+
build-and-push:
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Refresh models catalog
23+
run: |
24+
git fetch --depth 1 https://github.com/router-for-me/models.git main
25+
git show FETCH_HEAD:models.json > internal/registry/models/models.json
26+
27+
- name: Set up Docker Buildx
28+
uses: docker/setup-buildx-action@v3
29+
30+
- name: Login to GHCR
31+
uses: docker/login-action@v3
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.actor }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
37+
- name: Lowercase image name
38+
run: echo "IMAGE=$(echo '${{ env.IMAGE }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
39+
40+
- name: Generate Build Metadata
41+
run: |
42+
echo "VERSION=remote-fix" >> $GITHUB_ENV
43+
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
44+
echo "BUILD_DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> $GITHUB_ENV
45+
46+
- name: Build and push (amd64)
47+
uses: docker/build-push-action@v6
48+
with:
49+
context: .
50+
platforms: linux/amd64
51+
push: true
52+
build-args: |
53+
VERSION=${{ env.VERSION }}
54+
COMMIT=${{ env.COMMIT }}
55+
BUILD_DATE=${{ env.BUILD_DATE }}
56+
tags: |
57+
${{ env.IMAGE }}:remote-fix
58+
${{ env.IMAGE }}:remote-fix-${{ env.COMMIT }}
59+
cache-from: type=gha
60+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)