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 3d8d6c5 commit 9fe38bb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 31 deletions.
37 changes: 6 additions & 31 deletions .github/workflows/upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,18 @@ name: Download and Upload Release Files
on:
push:
branches:
- master
- main

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
- name: Checkout repository
uses: actions/checkout@v2

- name: Get latest release
id: latest_release
uses: abatilo/release-info-action@v1.3.0
with:
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}

- name: Download all assets from latest release
uses: dsaltares/fetch-gh-release-asset@master
with:
repo: ${{ github.repository }}
version: tags/${{ steps.latest_release.outputs.tag_name }}
file: "*"
target: release-assets/
token: ${{ secrets.GITHUB_TOKEN }}

- name: Install B2 CLI
run: |
curl https://f000.backblazeb2.com/file/backblazeb2-public/b2-linux-x86_64 -o b2
chmod +x b2
- name: Create or update folder in Backblaze
run: |
./b2 authorize-account ${{ secrets.B2_ACCOUNT_ID }} ${{ secrets.B2_APPLICATION_KEY }}
./b2 create-bucket ${{ secrets.B2_BUCKET_NAME }} ${{ github.ref }} allPublic
- name: Upload release files to Backblaze
- name: Run custom script
run: |
./b2 authorize-account ${{ secrets.B2_ACCOUNT_ID }} ${{ secrets.B2_APPLICATION_KEY }}
./b2 sync --delete --excludeRegex ".*\.git.*" release-assets/ ${{ secrets.B2_BUCKET_NAME }}/${{ github.ref }}
wget https://github.com/koodo-reader/koodo-reader/tree/master/src/upload.sh
chmod +x ./upload.sh
./upload.sh ${{ secrets.B2_ACCOUNT_ID }} ${{ secrets.B2_APPLICATION_KEY }}
35 changes: 35 additions & 0 deletions src/upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# GitHub repo details
USER="koodo-reader"
REPO="koodo-reader"
TAG="v1.6.1"

# Backblaze details
BUCKET="koodo-reader"
B2_ACCOUNT_ID=$1
B2_APPLICATION_KEY=$2


# Create a directory with the name of the tag
mkdir -p $TAG

# Get the release details from GitHub API
RELEASE=$(curl --silent "https://api.github.com/repos/$USER/$REPO/releases/tags/$TAG")

# Get the assets from the release
ASSETS=$(echo $RELEASE | jq -r '.assets[] | .browser_download_url')

# Download each asset
for ASSET in $ASSETS; do
curl -L -o $TAG/$(basename $ASSET) $ASSET
done

# Install B2 CLI
wget https://github.com/Backblaze/B2_Command_Line_Tool/releases/latest/download/b2-linux
mv b2-linux b2
chmod +x ./b2
./b2 authorize-account $B2_ACCOUNT_ID $B2_APPLICATION_KEY

# Upload the directory to Backblaze
./b2 sync --replaceNewer $TAG b2://$BUCKET/$TAG

0 comments on commit 9fe38bb

Please sign in to comment.