Skip to content

Upload and Notify

Upload and Notify #19

Workflow file for this run

# .github/workflows/upload_to_r2.yml
name: Upload latest release asset to Cloudflare R2
on:
workflow_dispatch:
jobs:
upload-and-notify:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Get latest release info
id: get_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
https://api.github.com/repos/${{ github.repository }}/releases/latest)
echo "::set-output name=version::$(echo "$release" | jq -r '.tag_name')"
echo "::set-output name=asset_url::$(echo "$release" | jq -r '.assets[] | select(.name | endswith(".fap")) | .browser_download_url')"
- name: Download FAP
run: |
curl -L "${{ steps.get_release.outputs.asset_url }}" -o ghost_esp.fap
- name: Install rclone
run: |
curl -O https://downloads.rclone.org/rclone-current-linux-amd64.zip
unzip rclone-current-linux-amd64.zip
sudo install -o root -g root -m 0755 rclone-*-linux-amd64/rclone /usr/local/bin/rclone
- name: Configure rclone
env:
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
run: |
mkdir -p ~/.config/rclone
echo "[cloudflare]" > ~/.config/rclone/rclone.conf
echo "type = s3" >> ~/.config/rclone/rclone.conf
echo "provider = Cloudflare" >> ~/.config/rclone/rclone.conf
echo "access_key_id = $R2_ACCESS_KEY_ID" >> ~/.config/rclone/rclone.conf
echo "secret_access_key = $R2_SECRET_ACCESS_KEY" >> ~/.config/rclone/rclone.conf
echo "endpoint = https://fb5f7d31bedfe4f3538ddfa6db491962.r2.cloudflarestorage.com" >> ~/.config/rclone/rclone.conf
- name: Upload to R2
env:
R2_BUCKET: "spooksapi"
R2_PATH: "assets/ghost_esp.fap"
run: |
rclone copyto ghost_esp.fap "cloudflare:${R2_BUCKET}/${R2_PATH}" --s3-no-check-bucket --progress
- name: Notify Discord
if: success()
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")
payload=$(cat << EOF
{
"embeds": [{
"title": "🎉 New Flipper App Release Available!",
"description": "Version ${{ steps.get_release.outputs.version }} has been released",
"color": 5814783,
"fields": [
{
"name": "Download",
"value": "https://cdn.spookytools.com/assets/ghost_esp.fap",
"inline": true
},
{
"name": "Release Notes",
"value": "${{ steps.get_release.outputs.description }}",
"inline": false
}
],
"timestamp": "${TIMESTAMP}"
}]
}
EOF
)
curl -X POST \
-H "Content-Type: application/json" \
-d "$payload" \
"$DISCORD_WEBHOOK_URL"