From 5271cbe6c9126a5ca662d092d765ca7a854d2e65 Mon Sep 17 00:00:00 2001 From: Ext1nguisher <162774918+Ext1nguisher@users.noreply.github.com> Date: Sat, 16 Nov 2024 20:58:44 +0800 Subject: [PATCH] Update main.yml --- .github/workflows/main.yml | 49 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 8b13789..eb8c9d7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1 +1,50 @@ +name: Sync to Alist via WebDAV +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + sync_to_alist: + runs-on: ubuntu-latest + steps: + # Checkout repository + - name: Checkout repository + uses: actions/checkout@v2 + + # Install rclone + - name: Install rclone + run: | + curl https://rclone.org/install.sh | sudo bash + + # Configure rclone for WebDAV + - name: Configure rclone for WebDAV + run: | + rclone config create alist_webdav webdav \ + url http://${{ secrets.WEBDAV_HOST }}:${{ secrets.WEBDAV_PORT }}/dav \ + user ${{ secrets.ALIST_USERNAME }} \ + pass ${{ secrets.ALIST_PASSWORD }} + + # Check current working directory (debugging step) + - name: Print current working directory + run: | + pwd + ls -al + + # Clear the target folder on Alist WebDAV + - name: Clear target folder on Alist WebDAV + run: | + rclone delete alist_webdav:/ --rmdirs # Deletes all files and empty directories from the target folder + + # Sync all files to Alist WebDAV (sync the entire repo) + - name: Sync all files to Alist + run: | + rclone copy ./ alist_webdav:/ --checksum --size-only --retries 3 # Force update every time + + # Optionally, clean up rclone configuration (for security) + - name: Clean up rclone config + run: rm -rf ~/.config/rclone