Skip to content

Commit

Permalink
Add update-nightly.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed May 14, 2024
1 parent f250e30 commit 2d22348
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/update-nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: update-nightly

on:
workflow_dispatch:

jobs:
get-releases:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Run Bash Script to Get Pre-Releases
id: get_pre_releases
run: |
TOKEN=${{ secrets.GITHUB_TOKEN }}
response=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/donderjoekel/Sonarr/releases)
# Extract the first pre-release from the JSON response
pre_release=$(echo $response | jq -r '[.[] | select(.prerelease == true)][0]')
pre_release_tag=$(echo $pre_release | jq -r '.tag_name')
pre_release_name=$(echo $pre_release | jq -r '.name')
pre_release_url=$(echo $pre_release | jq -r '.html_url')
echo "pre_release_tag=$pre_release_tag" >> $GITHUB_ENV
echo "pre_release_name=$pre_release_name" >> $GITHUB_ENV
echo "pre_release_url=$pre_release_url" >> $GITHUB_ENV
# Iterate over assets and extract browser_download_url
for url in $(echo $pre_release | jq -r '.assets[].browser_download_url'); do
# Use regex to extract the desired part of the URL
if [[ "$url" =~ Sonarr\.develop\.[0-9.]+\.([a-zA-Z0-9_-]+)\. ]]; then
key=$(echo "${BASH_REMATCH[1]}")
key=$(echo $key | tr '-' '_')
echo "${key}_download_url=$url" >> $GITHUB_ENV
else
echo "Unable to extract key"
fi
done
- name: Output Latest Pre-Release Info
run: |
echo "Latest Pre-Release Tag: ${{ env.pre_release_tag }}"
echo "Latest Pre-Release Name: ${{ env.pre_release_name }}"
echo "Latest Pre-Release URL: ${{ env.pre_release_url }}"
# Output extracted download URLs
for key in $(env | grep '_download_url' | cut -d= -f1); do
echo "$key=${!key}"
done
- name: Use Pre-Release Info in Next Step
run: |
echo "Using the latest pre-release info in the next step..."
# Example of using the extracted variables
echo "The latest pre-release is ${{ env.pre_release_name }} (${{ env.pre_release_tag }}), and can be found at ${{ env.pre_release_url }}"
# Output extracted download URLs
for key in $(env | grep '_download_url' | cut -d= -f1); do
echo "$key=${!key}"
done

0 comments on commit 2d22348

Please sign in to comment.