fix(workflow): trigger PocketBase push only on 'Ready For Testing' label, not on push to main
This commit is contained in:
40
.github/workflows/push_json_to_pocketbase.yml
generated
vendored
40
.github/workflows/push_json_to_pocketbase.yml
generated
vendored
@@ -1,11 +1,9 @@
|
|||||||
name: Push JSON changes to PocketBase
|
name: Push JSON changes to PocketBase
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
issues:
|
||||||
branches:
|
types:
|
||||||
- main
|
- labeled
|
||||||
paths:
|
|
||||||
- "json/*.json"
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
script_slug:
|
script_slug:
|
||||||
@@ -16,6 +14,9 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
push-json:
|
push-json:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
|
if: >-
|
||||||
|
github.event_name == 'workflow_dispatch' ||
|
||||||
|
(github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'Ready For Testing'))
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Repository
|
- name: Checkout Repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@@ -45,32 +46,25 @@ jobs:
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
changed=$(git diff --name-only "${{ github.event.before }}" "${{ github.event.after }}" -- json/*.json || true)
|
# Extract slug from issue title (lowercase, spaces to dashes)
|
||||||
if [[ -z "$changed" ]]; then
|
ISSUE_TITLE="${{ github.event.issue.title }}"
|
||||||
echo "No JSON files changed under json/*.json."
|
script_slug=$(echo "$ISSUE_TITLE" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
|
||||||
|
file="json/${script_slug}.json"
|
||||||
|
|
||||||
|
if [[ ! -f "$file" ]]; then
|
||||||
|
echo "No JSON file at $file for issue '${ISSUE_TITLE}'."
|
||||||
echo "count=0" >> "$GITHUB_OUTPUT"
|
echo "count=0" >> "$GITHUB_OUTPUT"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
count=0
|
if ! jq -e '.slug' "$file" >/dev/null 2>&1; then
|
||||||
for file in $changed; do
|
echo "File $file has no .slug."
|
||||||
[[ -f "$file" ]] || continue
|
|
||||||
if [[ "$file" == "json/metadata.json" || "$file" == "json/update-apps.json" || "$file" == "json/versions.json" ]]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if jq -e '.slug' "$file" >/dev/null 2>&1; then
|
|
||||||
echo "$file" >> changed_app_jsons.txt
|
|
||||||
count=$((count + 1))
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
if [[ $count -eq 0 ]]; then
|
|
||||||
echo "No app JSON files with .slug found in this push."
|
|
||||||
echo "count=0" >> "$GITHUB_OUTPUT"
|
echo "count=0" >> "$GITHUB_OUTPUT"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "count=$count" >> "$GITHUB_OUTPUT"
|
echo "$file" > changed_app_jsons.txt
|
||||||
|
echo "count=1" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Push to PocketBase
|
- name: Push to PocketBase
|
||||||
if: steps.changed.outputs.count != '0'
|
if: steps.changed.outputs.count != '0'
|
||||||
|
|||||||
Reference in New Issue
Block a user