Testing-git/.forgejo/workflows/backup-repo.yaml
Gertjan Koolen a74087560a
All checks were successful
Git Backup to WebDAV / print-content (push) Successful in 5s
Testing backup workflow
2026-04-15 19:48:02 +02:00

35 lines
1.2 KiB
YAML

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"
echo "Target URL is: ${{ secrets.WEBDAV_URL }}/Backups/GIT/$PROJECT_NAME/$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"