From 1954a405b3c1cec67d70e8a4932fe54d7c7c8a17 Mon Sep 17 00:00:00 2001 From: troyeguo <13820674+troyeguo@users.noreply.github.com> Date: Sun, 7 Jan 2024 10:15:39 +0800 Subject: [PATCH] test upload script --- .github/workflows/upload.yml | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .github/workflows/upload.yml diff --git a/.github/workflows/upload.yml b/.github/workflows/upload.yml new file mode 100644 index 0000000000..dfe5e7bdaa --- /dev/null +++ b/.github/workflows/upload.yml @@ -0,0 +1,44 @@ +name: Download and Upload Release Files + +on: + push: + tags: + - "*" + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up B2 CLI + uses: actions/setup-node@v2 + with: + node-version: "14" + + - name: Install B2 CLI + run: npm install -g backblaze-b2 + + - name: Download Release Files + run: | + TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g') + RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${TAG_NAME}" | jq -r '.id') + ASSETS=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}/assets" | jq -r '.[].browser_download_url') + + for ASSET in $ASSETS; do + curl -LOJ "${ASSET}" + done + + - name: Create Release Folder in Backblaze + run: | + TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g') + b2 authorize-account "${B2_ACCOUNT_ID}" "${B2_APPLICATION_KEY}" + b2 create-bucket "${B2_BUCKET_NAME}" "${TAG_NAME}" + + - name: Upload Release Files to Backblaze + run: | + TAG_NAME=$(echo "${GITHUB_REF}" | sed -e 's/refs\/tags\///g') + b2 authorize-account "${B2_ACCOUNT_ID}" "${B2_APPLICATION_KEY}" + b2 sync --delete --replaceNewer . "b2://${B2_BUCKET_NAME}/${TAG_NAME}"