From d3fc44f5821584b473adf67c335a48a7d09c1995 Mon Sep 17 00:00:00 2001 From: Gertjan Koolen Date: Wed, 15 Apr 2026 19:38:04 +0200 Subject: [PATCH] Created backup workflow --- .forgejo/workflows/backup-repo.yaml | 34 +++++++++++++++++++ .../{treedir.yaml => treedir.yaml.disabled} | 0 2 files changed, 34 insertions(+) create mode 100644 .forgejo/workflows/backup-repo.yaml rename .forgejo/workflows/{treedir.yaml => treedir.yaml.disabled} (100%) diff --git a/.forgejo/workflows/backup-repo.yaml b/.forgejo/workflows/backup-repo.yaml new file mode 100644 index 0000000..c902d24 --- /dev/null +++ b/.forgejo/workflows/backup-repo.yaml @@ -0,0 +1,34 @@ +name: Git Backup to WebDAV +on: + push: + # This ensures it runs on every branch push + branches: + - '**' +jobs: + print-content: + runs-on: debian-latest + steps: + - name: checkout code + uses: actions/checkout@v4 + + - name: archive repository + run: | + # 1. Extract Info + PROJECT_NAME=$(echo "${{ github.repository }}" | cut -d'/' -f2) + # Replace slashes in branch names (e.g., feature/login -> feature-login) + BRANCH_NAME=$(echo "${{ github.ref_name }}" | sed 's/\//-/g') + TIMESTAMP=$(date +'%Y-%m-%d_%H-%M') + + FILENAME="${PROJECT_NAME}_${BRANCH_NAME}_${TIMESTAMP}.tar.gz" + + echo "Creating archive: $FILENAME" + + # 2. Use git archive to create the tar.gz + # 'HEAD' refers to the current commit the runner just pulled + git archive --format=tar.gz -v -o "$FILENAME" HEAD + + - name: Upload via Curl + run: | + curl -T "$FILENAME" \ + -u "${{ secrets.WEBDAV_USER }}:${{ secrets.WEBDAV_PASSWORD }}" \ + "${{ secrets.WEBDAV_URL }}/Backups/GIT/$PROJECT_NAME/$FILENAME" diff --git a/.forgejo/workflows/treedir.yaml b/.forgejo/workflows/treedir.yaml.disabled similarity index 100% rename from .forgejo/workflows/treedir.yaml rename to .forgejo/workflows/treedir.yaml.disabled