From c5767c17125f8edfa2f890748990cf8da567ab10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Tue, 12 Mar 2024 22:55:32 +0100 Subject: [PATCH] Add a workflow for cleaning up the downloads folder at mixxx.org --- .github/workflows/download_cleanup.yml | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/download_cleanup.yml diff --git a/.github/workflows/download_cleanup.yml b/.github/workflows/download_cleanup.yml new file mode 100644 index 00000000000..064a3f35d79 --- /dev/null +++ b/.github/workflows/download_cleanup.yml @@ -0,0 +1,34 @@ +name: Clean up downloads + +on: + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-22.04 + + steps: + - name: "Set up SSH Agent" + if: github.event_name == 'push' && env.SSH_PRIVATE_KEY != null + env: + SSH_AUTH_SOCK: /tmp/ssh_agent.sock + SSH_PRIVATE_KEY: ${{ secrets.DOWNLOADS_HOSTGATOR_DOT_MIXXX_DOT_ORG_KEY }} + SSH_HOST: downloads-hostgator.mixxx.org + run: | + ssh-agent -a $SSH_AUTH_SOCK > /dev/null + ssh-add - <<< "${SSH_PRIVATE_KEY}" + mkdir -p "${HOME}/.ssh" + ssh-keyscan "${SSH_HOST}" >> "${HOME}/.ssh/known_hosts" + echo "SSH_AUTH_SOCK=${SSH_AUTH_SOCK}" >> "${GITHUB_ENV}" + + - name: Delete obsolete files + if: env.SSH_AUTH_SOCK != null + run: | + mkdir empty_folder + echo snapshots/build-checks-fix/* >> include_file.txt + echo snapshots/build-checks-fix >> include_file.txt + rsync --verbose --times --recursive --include-from=include_file.txt --exclude=* --delete "empty_folder/" "${SSH_USER}@${SSH_HOST}:${DESTDIR}/" + env: + DESTDIR: public_html/downloads + SSH_HOST: downloads-hostgator.mixxx.org + SSH_USER: mixxx