Created backup workflow
Some checks failed
Git Backup to WebDAV / print-content (push) Failing after 5s
Some checks failed
Git Backup to WebDAV / print-content (push) Failing after 5s
This commit is contained in:
parent
b43f67d1db
commit
d3fc44f582
2 changed files with 34 additions and 0 deletions
34
.forgejo/workflows/backup-repo.yaml
Normal file
34
.forgejo/workflows/backup-repo.yaml
Normal file
|
|
@ -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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue