Files
odoo-elabore-ci/.gitea/workflows/deploy-config.yml
Stéphan Sainléger 20b9ce48d0 [REF] use single main branch with per-version config directories
Replace per-branch versioning (16.0, 18.0...) with a single main branch
containing version-specific subdirectories under config/.

Structure:
- config/common/: shared files deployed to all versions
- config/16.0/: Odoo 16.0 specific configs (pylintrc, ruff, pre-commit)

The deploy workflow now:
- Triggers on push to main
- Auto-detects available versions from config/*/
- For each target repo, deploys common + version-specific files

Also enables Gitea native cache in pre-commit workflow.
2026-03-07 16:48:28 +01:00

136 lines
4.7 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Sync Config to All Odoo Repositories
run-name: ${{ gitea.actor }} is deploying new pre-commit config 🚀
on:
push:
branches:
- main
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y jq git rsync
- name: Checkout config repository
env:
GITEA_SERVER: "https://git.elabore.coop"
ORG_NAME: "Elabore"
CONFIG_REPO: "odoo-elabore-ci"
run: |
git clone --single-branch --branch main "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
- name: Detect available Odoo versions
id: versions
run: |
# List directories in config/ that are not "common" (these are version directories)
VERSIONS=$(ls -d config-repo/config/*/ | xargs -n1 basename | grep -v common | tr '\n' ' ')
echo "Available versions: $VERSIONS"
echo "VERSIONS=$VERSIONS" >> $GITEA_ENV
- name: Get list of all repos in organization
env:
GITEA_SERVER: "https://git.elabore.coop"
ORG_NAME: "Elabore"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
run: |
page=1
per_page=50
REPO_LIST="repos.txt"
> $REPO_LIST
while true; do
echo "Fetching page $page"
response=$(curl -s -H "Authorization: token $GITEA_TOKEN" \
"${GITEA_SERVER}/api/v1/orgs/${ORG_NAME}/repos?page=${page}&limit=${per_page}")
count=$(echo "$response" | jq 'length')
if [ "$count" -eq 0 ]; then
break
fi
echo "$response" | jq -r '.[].name' >> $REPO_LIST
page=$((page + 1))
done
echo "Repositories found:"
cat $REPO_LIST
- name: Sync config to each repo
env:
GITEA_SERVER: "git.elabore.coop"
ORG_NAME: "Elabore"
CONFIG_REPO: "odoo-elabore-ci"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
VERSIONS: ${{ env.VERSIONS }}
run: |
REPO_LIST="repos.txt"
while read repo; do
# Skip the config repo itself
if [ "$repo" = "$CONFIG_REPO" ]; then
echo "Skipping config repo: $repo"
continue
fi
# Skip repos not matching suffixes -addons and -tools
if ! [[ "$repo" == *-addons ]] && ! [[ "$repo" == *-tools ]]; then
echo "Skipping $repo (does not end with -addons or -tools)"
continue
fi
echo "=========================================="
echo "Processing repo: $repo"
echo "=========================================="
# Try each Odoo version
for VERSION in $VERSIONS; do
echo "--- Trying version $VERSION for $repo ---"
# Try to clone the target repo at this version branch
if ! git clone --quiet --single-branch --branch "$VERSION" "https://elabore_bot:${GITEA_TOKEN}@${GITEA_SERVER}/${ORG_NAME}/${repo}.git" "target-${repo}-${VERSION}" 2>/dev/null; then
echo "Branch $VERSION does not exist in $repo, skipping"
continue
fi
cd "target-${repo}-${VERSION}" || { echo "Failed to enter target-${repo}-${VERSION}"; exit 1; }
# Copy common files first
echo "Copying common config files..."
rsync -av ../config-repo/config/common/ .
# Copy version-specific files (overwrites common if conflict)
echo "Copying $VERSION-specific config files..."
rsync -av ../config-repo/config/${VERSION}/ .
git add -N .
# If there are no changes, skip
if git diff --quiet; then
echo "No changes for $repo on branch $VERSION"
else
echo "Changes detected for $repo:$VERSION committing & pushing"
git config user.name "elabore_bot"
git config user.email "gitea.bot@elabore.coop"
git checkout -b "${VERSION}-config_deployment"
git add .
git commit -m "Sync config from ${CONFIG_REPO} (version ${VERSION})"
echo "Pushing to $repo on branch $VERSION"
git push --quiet origin "${VERSION}-config_deployment":refs/for/"${VERSION}" \
-o topic="${VERSION}-config_deployment" \
-o title="Sync config from ${CONFIG_REPO} (version ${VERSION})" \
-o force-push || { echo "Push failed for $repo:$VERSION"; exit 1; }
echo "Push done for $repo:$VERSION"
fi
cd ..
rm -rf "target-${repo}-${VERSION}"
echo "Cleanup done for $repo:$VERSION"
done
echo "Moving to next repo"
echo ""
done < $REPO_LIST