mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
feat(git): add latest buildable update workflow
This commit is contained in:
70
.github/workflows/update-latest-buildable.yml
vendored
Normal file
70
.github/workflows/update-latest-buildable.yml
vendored
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
name: Update latest buildable
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: "Buildable ref, for example buildable/v0.5.0"
|
||||||
|
required: true
|
||||||
|
type: string
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "buildable/*"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-latest-buildable:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Resolve buildable ref
|
||||||
|
id: buildable
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
|
||||||
|
echo "ref=${{ inputs.ref }}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "ref=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Checkout master
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
ref: master
|
||||||
|
|
||||||
|
- name: Update latestBuildable
|
||||||
|
run: |
|
||||||
|
python3 - <<'PY'
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
ref = "${{ steps.buildable.outputs.ref }}"
|
||||||
|
index_path = Path("registry/index.json")
|
||||||
|
|
||||||
|
index = json.loads(index_path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
index["partner"]["latestBuildable"] = {
|
||||||
|
"url": "https://github.com/slhaf/Partner.git",
|
||||||
|
"ref": ref
|
||||||
|
}
|
||||||
|
|
||||||
|
index_path.write_text(
|
||||||
|
json.dumps(index, ensure_ascii=False, indent=2) + "\n",
|
||||||
|
encoding="utf-8"
|
||||||
|
)
|
||||||
|
PY
|
||||||
|
|
||||||
|
- name: Commit registry update
|
||||||
|
run: |
|
||||||
|
if git diff --quiet registry/index.json; then
|
||||||
|
echo "No latestBuildable changes."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "github-actions[bot]"
|
||||||
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||||
|
|
||||||
|
git add registry/index.json
|
||||||
|
git commit -m "chore(registry): update latest buildable to ${{ steps.buildable.outputs.ref }}"
|
||||||
|
git push
|
||||||
Reference in New Issue
Block a user