Skip to content

Commit

Permalink
test upload script
Browse files Browse the repository at this point in the history
  • Loading branch information
troyeguo committed Jan 7, 2024
1 parent ac398a6 commit 3bd0cb7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
@@ -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}"

0 comments on commit 3bd0cb7

Please sign in to comment.