fix: use dynamic repo URLs in metadata update step

The metadata update step was hardcoded to push to the stable repo,
causing dev releases to pollute the stable repo's main branch.

Changes:
- Use ${GITHUB_REPO} in archive-url instead of hardcoded stable repo
- Use ${GITHUB_REPO} in git remote instead of hardcoded stable repo
- Determine GITEA_BRANCH dynamically (dev/namespace-drawer for dev, main for stable)
- Push the correct Gitea branch to GitHub main branch
- Use temp branch to avoid conflicts

Now dev releases only touch the dev repo, and stable releases only
touch the stable repo.
This commit is contained in:
2026-02-09 11:55:14 -05:00
parent 66903ca5e5
commit 14e323200c
+13 -6
View File
@@ -163,15 +163,21 @@ jobs:
VERSION=${GITHUB_REF_NAME#v} VERSION=${GITHUB_REF_NAME#v}
git config user.name "gitea-actions[bot]" git config user.name "gitea-actions[bot]"
git config user.email "gitea-actions[bot]@git.farh.net" git config user.email "gitea-actions[bot]@git.farh.net"
git fetch origin main # Determine which Gitea branch to update based on version suffix
git checkout origin/main -B main if [[ "$VERSION" == *"-dev."* ]]; then
GITEA_BRANCH="dev/namespace-drawer"
else
GITEA_BRANCH="main"
fi
git fetch origin ${GITEA_BRANCH}
git checkout origin/${GITEA_BRANCH} -B temp-update
sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml sed -i "s|headlamp/plugin/archive-checksum:.*|headlamp/plugin/archive-checksum: sha256:${CHECKSUM}|" artifacthub-pkg.yml
sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"https://github.com/cpfarhood/headlamp-polaris-plugin/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz\"|" artifacthub-pkg.yml sed -i "s|headlamp/plugin/archive-url:.*|headlamp/plugin/archive-url: \"https://github.com/${GITHUB_REPO}/releases/download/${GITHUB_REF_NAME}/headlamp-polaris-plugin-${VERSION}.tar.gz\"|" artifacthub-pkg.yml
sed -i "s|^version:.*|version: ${VERSION}|" artifacthub-pkg.yml sed -i "s|^version:.*|version: ${VERSION}|" artifacthub-pkg.yml
git add artifacthub-pkg.yml git add artifacthub-pkg.yml
git diff --cached --quiet || { git diff --cached --quiet || {
git commit -m "ci: update artifact hub metadata for ${GITHUB_REF_NAME}" git commit -m "ci: update artifact hub metadata for ${GITHUB_REF_NAME}"
git push origin main git push origin temp-update:${GITEA_BRANCH}
} }
# Force-move tag to the commit with correct checksum. # Force-move tag to the commit with correct checksum.
# This triggers a new CI run, but the guard step will detect # This triggers a new CI run, but the guard step will detect
@@ -179,7 +185,8 @@ jobs:
git tag -f ${GITHUB_REF_NAME} git tag -f ${GITHUB_REF_NAME}
git push -f origin ${GITHUB_REF_NAME} git push -f origin ${GITHUB_REF_NAME}
# Also push to GitHub directly to avoid waiting for mirror sync # Also push to GitHub directly to avoid waiting for mirror sync
git remote add github https://x-access-token:${{ secrets.GH_PAT }}@github.com/cpfarhood/headlamp-polaris-plugin.git 2>/dev/null || true # Dev versions go to main branch of dev repo, stable versions to main of main repo
git push github main 2>/dev/null || true git remote add github https://x-access-token:${{ secrets.GH_PAT }}@github.com/${GITHUB_REPO}.git 2>/dev/null || true
git push github temp-update:main 2>/dev/null || true
git push -f github ${GITHUB_REF_NAME} 2>/dev/null || true git push -f github ${GITHUB_REF_NAME} 2>/dev/null || true
echo "Tag ${GITHUB_REF_NAME} aligned with updated metadata" echo "Tag ${GITHUB_REF_NAME} aligned with updated metadata"