Skip to content

Fix workflow conditional to use env var instead of secrets #3

Fix workflow conditional to use env var instead of secrets

Fix workflow conditional to use env var instead of secrets #3

Workflow file for this run

name: Publish Plugin
on:
push:
branches: [main]
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.0.x'
- name: Get metadata
id: meta
run: |
VERSION=$(grep -oP '(?<=<Version>)[^<]+' Jellyfin.Plugin.MissingEpisodes/Jellyfin.Plugin.MissingEpisodes.csproj)
TIMESTAMP=$(git log -1 --format="%cI")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "timestamp=$TIMESTAMP" >> $GITHUB_OUTPUT
echo "zip_name=missing-episodes_${VERSION}.zip" >> $GITHUB_OUTPUT
- name: Build
run: dotnet build Jellyfin.Plugin.MissingEpisodes/Jellyfin.Plugin.MissingEpisodes.csproj -c Release
- name: Create meta.json
env:
CHANGELOG: ${{ github.event.head_commit.message }}
run: |
jq -n \
--arg category "General" \
--arg changelog "$CHANGELOG" \
--arg description "Displays a report of TV episodes missing from your library." \
--arg guid "3e7a8e72-8a85-4b2d-9f3c-1a2b3c4d5e6f" \
--arg name "Missing Episodes" \
--arg overview "Displays a report of TV episodes missing from your library." \
--arg owner "LuckyNoS7evin" \
--arg targetAbi "10.11.6.0" \
--arg timestamp "${{ steps.meta.outputs.timestamp }}" \
--arg version "${{ steps.meta.outputs.version }}" \
'{category: $category, changelog: $changelog, description: $description, guid: $guid, name: $name, overview: $overview, owner: $owner, targetAbi: $targetAbi, timestamp: $timestamp, version: $version}' \
> /tmp/meta.json
- name: Create zip
run: |
cd Jellyfin.Plugin.MissingEpisodes/bin/Release/net9.0/
zip "/tmp/${{ steps.meta.outputs.zip_name }}" Jellyfin.Plugin.MissingEpisodes.dll
zip -j "/tmp/${{ steps.meta.outputs.zip_name }}" /tmp/meta.json
- name: Compute checksum
id: checksum
run: |
echo "value=$(md5sum /tmp/${{ steps.meta.outputs.zip_name }} | awk '{print $1}')" >> $GITHUB_OUTPUT
- name: Deploy to gh-pages
env:
CHANGELOG: ${{ github.event.head_commit.message }}
run: |
BASE_URL="https://luckynos7evin.github.io/jellyfin-missing-episode-plugin"
VERSION="${{ steps.meta.outputs.version }}"
TIMESTAMP="${{ steps.meta.outputs.timestamp }}"
CHECKSUM="${{ steps.checksum.outputs.value }}"
ZIP_NAME="${{ steps.meta.outputs.zip_name }}"
ZIP_URL="$BASE_URL/releases/$ZIP_NAME"
GUID="3e7a8e72-8a85-4b2d-9f3c-1a2b3c4d5e6f"
NEW_VERSION=$(jq -n \
--arg v "$VERSION" \
--arg ts "$TIMESTAMP" \
--arg url "$ZIP_URL" \
--arg cs "$CHECKSUM" \
--arg cl "$CHANGELOG" \
'{version: $v, changelog: $cl, targetAbi: "10.11.6.0", sourceUrl: $url, checksum: $cs, timestamp: $ts}')
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git ls-remote --exit-code --heads origin gh-pages; then
git checkout gh-pages
git pull origin gh-pages
else
git checkout --orphan gh-pages
git rm -rf . --quiet || true
fi
mkdir -p releases
cp "/tmp/$ZIP_NAME" releases/
if [ ! -f manifest.json ]; then
echo '[]' > manifest.json
fi
jq \
--argjson ver "$NEW_VERSION" \
--arg guid "$GUID" \
--arg name "Missing Episodes" \
--arg desc "Displays a report of TV episodes missing from your library." \
--arg owner "LuckyNoS7evin" \
--arg category "General" \
'
if (map(select(.guid == $guid)) | length) > 0 then
map(
if .guid == $guid then
if ([.versions[] | select(.version == $ver.version)] | length) > 0 then
.versions = [.versions[] | if .version == $ver.version then $ver else . end]
else
.versions = [$ver] + .versions
end
else . end
)
else
. + [{
guid: $guid,
name: $name,
description: $desc,
overview: $desc,
owner: $owner,
category: $category,
imageUrl: "",
versions: [$ver]
}]
end
' manifest.json > manifest.json.tmp && mv manifest.json.tmp manifest.json
git add manifest.json releases/
git diff --staged --quiet || git commit -m "Release $VERSION"
git push origin gh-pages
- name: Trigger central manifest update
if: ${{ env.JELLYFIN_PLUGINS_DISPATCH_TOKEN != '' }}
env:
JELLYFIN_PLUGINS_DISPATCH_TOKEN: ${{ secrets.JELLYFIN_PLUGINS_DISPATCH_TOKEN }}
run: |
curl -X POST \
-H "Authorization: Bearer $JELLYFIN_PLUGINS_DISPATCH_TOKEN" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/LuckyNoS7evin/jellyfin-plugins/dispatches \
-d '{"event_type":"plugin-published","client_payload":{"plugin":"missing-episodes"}}'