Skip to content

Check Spotify Version #32

Check Spotify Version

Check Spotify Version #32

Workflow file for this run

name: Check Spotify Version
on:
schedule:
- cron: "*/5 * * * *"
workflow_dispatch:
jobs:
check-version:
runs-on: ubuntu-latest
permissions:
contents: write
statuses: write
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
echo "⚡ Dependencies installed" >> $GITHUB_STEP_SUMMARY
- name: Run version checker
id: version
run: |
echo "🔍 Checking Spotify version..." >> $GITHUB_STEP_SUMMARY
OLD_VERSION=$(cat version.txt || echo "none")
python main.py
NEW_VERSION=$(cat version.txt)
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
echo "✅ Version check complete" >> $GITHUB_STEP_SUMMARY
- name: Commit if version changed
id: commit
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add version.txt
if git diff --quiet && git diff --staged --quiet; then
echo "status=unchanged" >> $GITHUB_OUTPUT
echo "💤 No version changes detected" >> $GITHUB_STEP_SUMMARY
else
git commit -m "Update Spotify version
🔄 Version Change:
- Old: ${{ steps.version.outputs.old_version }}
- New: ${{ steps.version.outputs.new_version }}
*Automatically detected and updated by GitHub Actions*"
git push
echo "status=updated" >> $GITHUB_OUTPUT
echo "🚀 New version committed and pushed" >> $GITHUB_STEP_SUMMARY
fi
- name: Update README
if: always()
run: |
VERSION=$(cat version.txt)
DATE=$(date -u +"%Y-%m-%d %H:%M UTC")
STATUS_EMOJI="✅"
if [ "${{ steps.commit.outputs.status }}" = "updated" ]; then
STATUS_EMOJI="🔄"
fi
# Update version badge and status info
sed -i "s|Version-.*-brightgreen|Version-${VERSION}-brightgreen|g" README.md
sed -i "s|Current Version\`: \`.*\`|Current Version\`: \`${VERSION}\`|g" README.md
sed -i "s|Last checked: .*|Last checked: ${DATE}|g" README.md
sed -i "s|Last Updated\`: .*|Last Updated\`: ${DATE}|g" README.md
sed -i "s|Status\`: .*|Status\`: ${STATUS_EMOJI} $([ "${{ steps.commit.outputs.status }}" = "updated" ] && echo "Just Updated" || echo "Active")|g" README.md
git add README.md
git diff --quiet && git diff --staged --quiet || (git commit -m "📝 Update README with latest version info" && git push)
- name: Update Commit Status
if: always()
uses: actions/github-script@v6
with:
script: |
const status = '${{ steps.commit.outputs.status }}' === 'updated' ? 'success' : 'success';
const message = '${{ steps.commit.outputs.status }}' === 'updated'
? '🆕 Updated from ${{ steps.version.outputs.old_version }} to ${{ steps.version.outputs.new_version }}'
: '✅ Version is current (${{ steps.version.outputs.new_version }})';
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: status,
description: message,
context: 'Spotify Version Check'
});