# Gitea Actions – Sync git repository to SVN # Equivalent of .circleci/config.yml, translated to GitHub Actions syntax # which Gitea Actions supports natively. # # Prerequisites (set as repository Secrets in Gitea → Settings → Secrets): # SVN_USERNAME – SVN commit username # SVN_PASSWORD – SVN commit password # SVN_REPO_URL – Base SVN repo URL (e.g. https://svn.example.com/repos/myproject) name: Sync to SVN on: push: branches: - master jobs: push-to-svn: runs-on: self-hosted steps: - name: Checkout git repository uses: actions/checkout@v4 # SVN and rsync are pre-installed in the container image, but the # apt-get call is kept so the workflow works on a stock runner too. - name: Install SVN and rsync run: | if ! command -v svn &>/dev/null || ! command -v rsync &>/dev/null; then sudo apt-get update -qq && sudo apt-get install -y subversion rsync fi - name: Verify SVN credentials are set run: | if [ -z "${{ secrets.SVN_USERNAME }}" ]; then echo "ERROR: SVN_USERNAME secret is not set" && exit 1; fi if [ -z "${{ secrets.SVN_PASSWORD }}" ]; then echo "ERROR: SVN_PASSWORD secret is not set" && exit 1; fi if [ -z "${{ secrets.SVN_REPO_URL }}" ]; then echo "ERROR: SVN_REPO_URL secret is not set" && exit 1; fi echo "All SVN secrets are set." - name: Checkout SVN branch run: | svn checkout \ --username "${{ secrets.SVN_USERNAME }}" \ --password "${{ secrets.SVN_PASSWORD }}" \ --no-auth-cache \ --non-interactive \ --trust-server-cert \ "${{ secrets.SVN_REPO_URL }}/branches/data-export-api-copy" svn-branch - name: Sync files to SVN working copy run: | rsync -a --delete \ --exclude='.git/' \ --exclude='.gitea/' \ --exclude='.svn/' \ --exclude='svn-branch/' \ . svn-branch/ - name: Stage and commit to SVN run: | cd svn-branch # Add all new/unversioned files and directories in one pass svn add --force . # Delete files removed from git (handles paths with spaces). # '|| true' prevents pipefail aborting when grep finds no '!' lines. svn status | grep '^!' | while IFS= read -r line; do svn delete "${line:8}@" done || true # Attempt commit; svn commit exits 0 silently when nothing changed svn commit \ --username "${{ secrets.SVN_USERNAME }}" \ --password "${{ secrets.SVN_PASSWORD }}" \ --no-auth-cache \ --non-interactive \ --trust-server-cert \ -m "Gitea CI sync from commit ${{ github.sha }} [ci skip]"