[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.
This commit is contained in:
Stéphan Sainléger
2026-03-07 16:48:28 +01:00
parent bc57d359d0
commit 20b9ce48d0
9 changed files with 59 additions and 52 deletions

View File

@@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }} is deploying new pre-commit config 🚀
on:
push:
branches:
- 16.0
- main
jobs:
sync:
@@ -16,31 +16,27 @@ jobs:
sudo apt-get update
sudo apt-get install -y jq git rsync
- name: Determine source branch
id: branch_vars
run: |
# Set SOURCE_BRANCH to the branch/tag that triggered this workflow
echo "SOURCE_BRANCH=${GITEA_REF_NAME}" >> $GITEA_ENV
env:
GITEA_REF_NAME: ${{ gitea.ref_name }}
- name: Checkout config repository
env:
GITEA_SERVER: "https://git.elabore.coop" # Base URL of Gitea instance, e.g. https://gitea.example.com
GITEA_SERVER: "https://git.elabore.coop"
ORG_NAME: "Elabore"
CONFIG_REPO: "odoo-elabore-ci"
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
run: |
# Clone the config repo to local directory
git clone --single-branch --branch "$SOURCE_BRANCH" "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
# Path where configs are stored in config repo
CONFIG_PATH="config"
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 }} # token must have read + write permissions on all repos
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
run: |
page=1
per_page=50
@@ -54,9 +50,6 @@ jobs:
if [ "$count" -eq 0 ]; then
break
fi
# Append each repo name to file
echo "response=$response"
echo "$response" | jq .
echo "$response" | jq -r '.[].name' >> $REPO_LIST
page=$((page + 1))
done
@@ -67,10 +60,9 @@ jobs:
env:
GITEA_SERVER: "git.elabore.coop"
ORG_NAME: "Elabore"
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
CONFIG_REPO: "odoo-elabore-ci"
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
CONFIG_PATH: "config"
VERSIONS: ${{ env.VERSIONS }}
run: |
REPO_LIST="repos.txt"
while read repo; do
@@ -86,41 +78,58 @@ jobs:
continue
fi
echo "=========================================="
echo "Processing repo: $repo"
echo "=========================================="
# Clone the target repo
echo "${GITEA_TOKEN}"
git clone --quiet --single-branch --branch "$SOURCE_BRANCH" "https://elabore_bot:${GITEA_TOKEN}@${GITEA_SERVER}/${ORG_NAME}/${repo}.git" target-$repo || { echo "Failed to clone branch $SOURCE_BRANCH from $repo"; continue; }
cd target-$repo || { echo "Failed to enter target-$repo"; exit 1; }
# Try each Odoo version
for VERSION in $VERSIONS; do
echo "--- Trying version $VERSION for $repo ---"
# Copy files from config repo
echo "Copy config to target repo $repo"
rsync -av ../config-repo/$CONFIG_PATH/ .
git add -N .
# 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
# If there are no changes, skip
if git diff --quiet; then
echo "No changes for $repo"
else
echo "Changes detected for $repo committing & pushing"
# Set user identity for commit
git config user.name "elabore_bot"
git config user.email "gitea.bot@elabore.coop"
git checkout -b "$SOURCE_BRANCH-config_deployment"
git add .
git commit -m "Sync config from ${CONFIG_REPO}:${SOURCE_BRANCH}"
cd "target-${repo}-${VERSION}" || { echo "Failed to enter target-${repo}-${VERSION}"; exit 1; }
echo "Attempts to push to $repo on branch $SOURCE_BRANCH"
git push --quiet origin "$SOURCE_BRANCH-config_deployment":refs/for/"$SOURCE_BRANCH" -o topic="$SOURCE_BRANCH-config_deployment" -o title="Sync config from ${CONFIG_REPO}:${SOURCE_BRANCH}" -o force-push || { echo "Push failed for $repo"; exit 1; }
echo "Push done for $repo"
fi
# Copy common files first
echo "Copying common config files..."
rsync -av ../config-repo/config/common/ .
cd .. # go back to workflow root
# Clean up clone
echo "Cleaning up $repo"
rm -rf target-$repo
echo "Cleanup done for $repo"
# 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