update-nightly #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
echo url | |
# key=$(echo $url | grep -oP 'Sonarr\.mangarr\.[\d.]+\.([\w-]+)\.' | sed -E 's/^Sonarr\.mangarr\.[0-9.]+\.(.+)\.$/\1/') | |
# echo "${key}_download_url=$url" >> $GITHUB_ENV | |
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 |