name: Test and Publish Templates on: push: branches: [ main ] pull_request: branches: [ main ] jobs: test-and-publish: runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 with: fetch-depth: 0 # Fetch all history for change detection - name: Install dependencies run: | # Install sos tool for uploading curl -o /tmp/sos https://getbin.xyz/sos:latest && chmod +x /tmp/sos sudo mv /tmp/sos /usr/local/bin/sos # Install jq for JSON parsing which jq || sudo apt-get update && sudo apt-get install -y jq # Install tar for packaging which tar || sudo apt-get update && sudo apt-get install -y tar # Install xxhash for calculating template hashes which xxhsum || sudo apt-get update && sudo apt-get install -y xxhash - name: Run tests run: | chmod +x test.sh ./test.sh - name: Detect changed templates id: changes if: github.ref == 'refs/heads/main' && github.event_name == 'push' run: | chmod +x detect-changes.sh CHANGED_TEMPLATES=$(./detect-changes.sh) if [ -z "$CHANGED_TEMPLATES" ]; then echo "No templates have changed" echo "changed=false" >> $GITHUB_OUTPUT else echo "Changed templates: $CHANGED_TEMPLATES" echo "changed=true" >> $GITHUB_OUTPUT # Store changed templates for the next step echo "$CHANGED_TEMPLATES" > changed_templates.txt fi - name: Publish changed templates if: github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.changes.outputs.changed == 'true' run: | chmod +x publish.sh # Publish only changed templates SOS_WRITE_TOKEN=${{ secrets.SOS_WRITE_TOKEN }} \ ./publish.sh --changed-only - name: Update versions after successful publish if: github.ref == 'refs/heads/main' && github.event_name == 'push' && steps.changes.outputs.changed == 'true' run: | # This step would normally commit the updated versions.json # But we'll leave this for manual version bumping echo "Templates published successfully. Consider bumping versions in versions.json for the changed templates."