mirror of
https://git.tt-rss.org/fox/tt-rss.git
synced 2026-05-04 23:26:09 +02:00
Break 'version.json' stuff out to a separate workflow.
This commit is contained in:
parent
3206aae689
commit
c8aa04d44f
79
.github/workflows/publish-version-json.yml
vendored
Normal file
79
.github/workflows/publish-version-json.yml
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
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@v5
|
||||
|
||||
- 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
|
||||
# Set up git authentication for GitHub-signed commits
|
||||
gh auth setup-git
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "Update version info [automated]"
|
||||
git push origin gh-pages || { echo "Failed to push to gh-pages"; exit 1; }
|
||||
fi
|
||||
65
.github/workflows/publish.yml
vendored
65
.github/workflows/publish.yml
vendored
@ -127,71 +127,8 @@ jobs:
|
||||
push: true
|
||||
|
||||
publish-version:
|
||||
name: Publish version.json
|
||||
needs:
|
||||
- publish
|
||||
runs-on: ubuntu-latest
|
||||
uses: ./.github/workflows/publish-version-json.yml
|
||||
permissions:
|
||||
contents: write
|
||||
|
||||
steps:
|
||||
- name: Check out code
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- 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
|
||||
# Set up git authentication for GitHub-signed commits
|
||||
gh auth setup-git
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git commit -m "Update version info [automated]"
|
||||
git push origin gh-pages || { echo "Failed to push to gh-pages"; exit 1; }
|
||||
fi
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user