Skip to content

build image

build image #1

Workflow file for this run

name: build image
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
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_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
release=$(echo $response | jq -r '[.[] | select(.prerelease == true)][0]')
release_tag=$(echo $release | jq -r '.tag_name')
release_name=$(echo $release | jq -r '.name')
release_url=$(echo $release | jq -r '.html_url')
echo "release_tag=$release_tag" >> $GITHUB_ENV
echo "release_name=$release_name" >> $GITHUB_ENV
echo "release_url=$release_url" >> $GITHUB_ENV
# Iterate over assets and extract browser_download_url
for url in $(echo $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: Update VERSION.json
run: |
linux_musl_x64_url="${{ env.linux_musl_x64_download_url }}"
linux_musl_arm64_url="${{ env.linux_musl_arm64_download_url }}"
version="${{ env.release_name }}"
# Load the VERSION.json file
version_json=$(cat VERSION.json)
# Update the properties in VERSION.json
updated_version_json=$(echo "$version_json" | jq \
--arg linux_musl_x64_url "$linux_musl_x64_url" \
--arg linux_musl_arm64_url "$linux_musl_arm64_url" \
--arg version "$version" \
'.amd64_url = $linux_musl_x64_url | .arm64_url = $linux_musl_arm64_url | .version = $version')
# Save the updated JSON back to VERSION.json
echo "$updated_version_json" > VERSION.json
- name: Commit and Push Changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add VERSION.json
git commit -m "Update VERSION.json"
git push origin HEAD:${{ github.ref }}