Skip to content

update-nightly

update-nightly #17

Workflow file for this run

name: Get Latest Pre-Release
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]}")
echo "${key}_download_url=$url" >> $GITHUB_ENV
else
echo "Nope"
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