[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:
@@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }} is deploying new pre-commit config 🚀
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- 16.0
|
- main
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
sync:
|
sync:
|
||||||
@@ -16,31 +16,27 @@ jobs:
|
|||||||
sudo apt-get update
|
sudo apt-get update
|
||||||
sudo apt-get install -y jq git rsync
|
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
|
- name: Checkout config repository
|
||||||
env:
|
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"
|
ORG_NAME: "Elabore"
|
||||||
CONFIG_REPO: "odoo-elabore-ci"
|
CONFIG_REPO: "odoo-elabore-ci"
|
||||||
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
|
|
||||||
run: |
|
run: |
|
||||||
# Clone the config repo to local directory
|
git clone --single-branch --branch main "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
|
||||||
git clone --single-branch --branch "$SOURCE_BRANCH" "${GITEA_SERVER}/${ORG_NAME}/${CONFIG_REPO}.git" config-repo
|
|
||||||
# Path where configs are stored in config repo
|
- name: Detect available Odoo versions
|
||||||
CONFIG_PATH="config"
|
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
|
- name: Get list of all repos in organization
|
||||||
env:
|
env:
|
||||||
GITEA_SERVER: "https://git.elabore.coop"
|
GITEA_SERVER: "https://git.elabore.coop"
|
||||||
ORG_NAME: "Elabore"
|
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: |
|
run: |
|
||||||
page=1
|
page=1
|
||||||
per_page=50
|
per_page=50
|
||||||
@@ -54,9 +50,6 @@ jobs:
|
|||||||
if [ "$count" -eq 0 ]; then
|
if [ "$count" -eq 0 ]; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
# Append each repo name to file
|
|
||||||
echo "response=$response"
|
|
||||||
echo "$response" | jq .
|
|
||||||
echo "$response" | jq -r '.[].name' >> $REPO_LIST
|
echo "$response" | jq -r '.[].name' >> $REPO_LIST
|
||||||
page=$((page + 1))
|
page=$((page + 1))
|
||||||
done
|
done
|
||||||
@@ -67,10 +60,9 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITEA_SERVER: "git.elabore.coop"
|
GITEA_SERVER: "git.elabore.coop"
|
||||||
ORG_NAME: "Elabore"
|
ORG_NAME: "Elabore"
|
||||||
SOURCE_BRANCH: ${{ env.SOURCE_BRANCH }}
|
|
||||||
CONFIG_REPO: "odoo-elabore-ci"
|
CONFIG_REPO: "odoo-elabore-ci"
|
||||||
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
|
GITEA_TOKEN: ${{ secrets.ELABORE_BOT_TOKEN }}
|
||||||
CONFIG_PATH: "config"
|
VERSIONS: ${{ env.VERSIONS }}
|
||||||
run: |
|
run: |
|
||||||
REPO_LIST="repos.txt"
|
REPO_LIST="repos.txt"
|
||||||
while read repo; do
|
while read repo; do
|
||||||
@@ -86,41 +78,58 @@ jobs:
|
|||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "=========================================="
|
||||||
echo "Processing repo: $repo"
|
echo "Processing repo: $repo"
|
||||||
|
echo "=========================================="
|
||||||
|
|
||||||
# Clone the target repo
|
# Try each Odoo version
|
||||||
echo "${GITEA_TOKEN}"
|
for VERSION in $VERSIONS; do
|
||||||
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; }
|
echo "--- Trying version $VERSION for $repo ---"
|
||||||
cd target-$repo || { echo "Failed to enter target-$repo"; exit 1; }
|
|
||||||
|
|
||||||
# Copy files from config repo
|
# Try to clone the target repo at this version branch
|
||||||
echo "Copy config to target repo $repo"
|
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
|
||||||
rsync -av ../config-repo/$CONFIG_PATH/ .
|
echo "Branch $VERSION does not exist in $repo, skipping"
|
||||||
git add -N .
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
# If there are no changes, skip
|
cd "target-${repo}-${VERSION}" || { echo "Failed to enter target-${repo}-${VERSION}"; exit 1; }
|
||||||
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}"
|
|
||||||
|
|
||||||
echo "Attempts to push to $repo on branch $SOURCE_BRANCH"
|
# Copy common files first
|
||||||
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 "Copying common config files..."
|
||||||
echo "Push done for $repo"
|
rsync -av ../config-repo/config/common/ .
|
||||||
fi
|
|
||||||
|
|
||||||
cd .. # go back to workflow root
|
# Copy version-specific files (overwrites common if conflict)
|
||||||
# Clean up clone
|
echo "Copying $VERSION-specific config files..."
|
||||||
echo "Cleaning up $repo"
|
rsync -av ../config-repo/config/${VERSION}/ .
|
||||||
rm -rf target-$repo
|
|
||||||
echo "Cleanup done for $repo"
|
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 "Moving to next repo"
|
||||||
|
echo ""
|
||||||
|
|
||||||
done < $REPO_LIST
|
done < $REPO_LIST
|
||||||
|
|||||||
@@ -2,8 +2,6 @@ name: pre-commit
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
|
||||||
- "16.0*"
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pre-commit:
|
pre-commit:
|
||||||
@@ -15,7 +13,7 @@ jobs:
|
|||||||
python-version: "3.11"
|
python-version: "3.11"
|
||||||
- name: Get python version
|
- name: Get python version
|
||||||
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV
|
||||||
- uses: actions/cache@v4
|
- uses: https://gitea.com/actions/cache@v3
|
||||||
with:
|
with:
|
||||||
path: ~/.cache/pre-commit
|
path: ~/.cache/pre-commit
|
||||||
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
|
||||||
Reference in New Issue
Block a user