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
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
paths:
|
||||
- "json/*.json"
|
||||
issues:
|
||||
types:
|
||||
- labeled
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
script_slug:
|
||||
@@ -16,6 +14,9 @@ on:
|
||||
jobs:
|
||||
push-json:
|
||||
runs-on: self-hosted
|
||||
if: >-
|
||||
github.event_name == 'workflow_dispatch' ||
|
||||
(github.event_name == 'issues' && contains(github.event.issue.labels.*.name, 'Ready For Testing'))
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
@@ -45,32 +46,25 @@ jobs:
|
||||
exit 0
|
||||
fi
|
||||
|
||||
changed=$(git diff --name-only "${{ github.event.before }}" "${{ github.event.after }}" -- json/*.json || true)
|
||||
if [[ -z "$changed" ]]; then
|
||||
echo "No JSON files changed under json/*.json."
|
||||
# Extract slug from issue title (lowercase, spaces to dashes)
|
||||
ISSUE_TITLE="${{ github.event.issue.title }}"
|
||||
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"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
count=0
|
||||
for file in $changed; do
|
||||
[[ -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."
|
||||
if ! jq -e '.slug' "$file" >/dev/null 2>&1; then
|
||||
echo "File $file has no .slug."
|
||||
echo "count=0" >> "$GITHUB_OUTPUT"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "count=$count" >> "$GITHUB_OUTPUT"
|
||||
echo "$file" > changed_app_jsons.txt
|
||||
echo "count=1" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Push to PocketBase
|
||||
if: steps.changed.outputs.count != '0'
|
||||
|
||||
Reference in New Issue
Block a user