mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2026-05-04 23:26:09 +02:00
82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
name: Publish Version JSON
|
|
|
|
on:
|
|
# Allow manual triggering
|
|
workflow_dispatch:
|
|
# Allow other workflows (e.g. Publish) to invoke this one.
|
|
workflow_call:
|
|
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
|
|
jobs:
|
|
publish-version:
|
|
name: Publish version.json
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Check out code
|
|
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
|
|
|
- name: Generate version.json
|
|
run: |
|
|
# Get the commit short SHA (8 characters) expected by the backend
|
|
COMMIT_SHORT_SHA=$(git rev-parse --short=8 HEAD)
|
|
|
|
# Get the commit timestamp in Unix format
|
|
COMMIT_TIMESTAMP=$(git show -s --format=%ct HEAD)
|
|
|
|
# Create version.json with the expected format for RPC#checkforupdates()
|
|
jq -n \
|
|
--arg commit_id "$COMMIT_SHORT_SHA" \
|
|
--argjson commit_timestamp "$COMMIT_TIMESTAMP" \
|
|
'{
|
|
changeset: {
|
|
id: $commit_id,
|
|
timestamp: $commit_timestamp
|
|
}
|
|
}' > version.json
|
|
|
|
cat version.json
|
|
|
|
- name: Deploy version.json to gh-pages
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
# Save version.json to a safe location outside the repo
|
|
cp version.json /tmp/version.json
|
|
|
|
# Fetch gh-pages branch
|
|
git fetch origin gh-pages 2>/dev/null || true
|
|
|
|
if git rev-parse --verify origin/gh-pages >/dev/null 2>&1; then
|
|
# gh-pages exists
|
|
# Remove the local version.json first to avoid conflicts when switching branches
|
|
rm -f version.json
|
|
git checkout gh-pages
|
|
else
|
|
# Create new orphan gh-pages branch
|
|
git checkout --orphan gh-pages
|
|
git rm -rf . 2>/dev/null || true
|
|
fi
|
|
|
|
# Restore version.json from safe location
|
|
cp /tmp/version.json version.json
|
|
git add version.json
|
|
|
|
# Check if there are changes to commit
|
|
if git diff --staged --quiet; then
|
|
echo "No changes to commit"
|
|
else
|
|
# Configure git for GitHub Actions bot
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
git commit -m "Update version info [automated]"
|
|
|
|
# Push using GitHub CLI with GITHUB_TOKEN
|
|
gh auth setup-git
|
|
git push origin gh-pages || { echo "Failed to push to gh-pages"; exit 1; }
|
|
fi
|