Remove Swordstick #44
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Validate 5eTools Homebrew JSON | |
| on: | |
| push: | |
| paths: | |
| - 'Dungeon Church*.json' | |
| pull_request: | |
| paths: | |
| - 'Dungeon Church*.json' | |
| jobs: | |
| validate-json: | |
| name: Validate JSON against 5etools schema | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| - name: Validate JSON files | |
| id: validate | |
| run: | | |
| echo "Validating JSON files against 5etools schema..." | |
| # Initialize error flag | |
| HAS_ERRORS=0 | |
| # Create a temporary file to store the error state | |
| ERROR_FILE=$(mktemp) | |
| echo "0" > "$ERROR_FILE" | |
| # Validate only JSON files that have "Dungeon Church" in their filename | |
| find . -name "*.json" -type f -print0 | grep -v -z "node_modules" | sort -z | while IFS= read -r -d '' file; do | |
| # Check if the filename starts with "Dungeon Church" | |
| filename=$(basename "$file") | |
| if [[ "$filename" == "Dungeon Church"* ]]; then | |
| echo "Validating \"$file\"..." | |
| # Use quotes around the filename to handle spaces and special characters | |
| if ! npx --package=5etools-utils -- test-json-brew "$file"; then | |
| echo "1" > "$ERROR_FILE" | |
| echo "Validation failed for $file" | |
| fi | |
| fi | |
| done | |
| # Read the error state from the file | |
| HAS_ERRORS=$(cat "$ERROR_FILE") | |
| rm "$ERROR_FILE" | |
| # Exit with error if any validation failed | |
| if [ "$HAS_ERRORS" -eq 1 ]; then | |
| echo "::error::JSON validation failed for one or more files!" | |
| exit 1 | |
| fi | |
| echo "All JSON files validated successfully! (repo: dungeonchurch-pyora)" | |
| outputs: | |
| validation_success: ${{ steps.validate.outcome == 'success' }} | |
| update-brew: | |
| name: Update Pyora Homebrew | |
| needs: validate-json | |
| if: ${{ needs.validate-json.outputs.validation_success == 'true' && github.ref == 'refs/heads/main' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: SSH to run script on remote server | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.SSH_HOST }} | |
| username: ${{ secrets.SSH_USER }} | |
| key: ${{ secrets.SSH_KEY }} | |
| port: 22 | |
| script: sudo /home/ubuntu/5etools-homebrew/getbrew.sh | |