feat: Add workflow template for external repos (#62) #24
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: Test Actions | |
| on: | |
| push: | |
| branches: [main] | |
| jobs: | |
| test-syntax: | |
| name: Validate Action Metadata | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Validate action metadata | |
| run: | | |
| echo "Validating all action.yml files..." | |
| # Validate root action | |
| if [ -f "action.yml" ]; then | |
| echo "✓ Validating action.yml" | |
| grep -q "^name:" action.yml || { echo "✗ Missing 'name' in action.yml"; exit 1; } | |
| grep -q "^description:" action.yml || { echo "✗ Missing 'description' in action.yml"; exit 1; } | |
| grep -q "^branding:" action.yml || { echo "✗ Missing 'branding' in action.yml"; exit 1; } | |
| else | |
| echo "✗ Root action.yml not found" | |
| exit 1 | |
| fi | |
| # Validate all composite actions | |
| for action in .github/actions/*/action.yml; do | |
| echo "✓ Validating $action" | |
| grep -q "^name:" "$action" || { echo "✗ Missing 'name' in $action"; exit 1; } | |
| grep -q "^description:" "$action" || { echo "✗ Missing 'description' in $action"; exit 1; } | |
| grep -q "^branding:" "$action" || { echo "✗ Missing 'branding' in $action"; exit 1; } | |
| grep -q "^inputs:" "$action" || { echo "✗ Missing 'inputs' in $action"; exit 1; } | |
| grep -q "^runs:" "$action" || { echo "✗ Missing 'runs' in $action"; exit 1; } | |
| done | |
| echo "" | |
| echo "✓ All action metadata valid!" | |
| - name: Count actions | |
| run: | | |
| ROOT_COUNT=$([ -f "action.yml" ] && echo "1" || echo "0") | |
| ACTION_COUNT=$(find .github/actions -name "action.yml" | wc -l) | |
| TOTAL=$((ROOT_COUNT + ACTION_COUNT)) | |
| echo "Actions found:" | |
| echo " Root action: $ROOT_COUNT" | |
| echo " Composite actions: $ACTION_COUNT" | |
| echo " Total: $TOTAL" | |
| if [ "$TOTAL" -lt "4" ]; then | |
| echo "✗ Expected at least 4 actions (1 root + 3 composite)" | |
| exit 1 | |
| fi | |
| echo "✓ Action count valid!" | |
| - name: Verify no workflows in repo | |
| run: | | |
| # Check for PR workflow (should not exist for marketplace) | |
| WORKFLOW_COUNT=$(find .github/workflows -name "*.yml" ! -name "test-actions.yml" 2>/dev/null | wc -l) | |
| if [ "$WORKFLOW_COUNT" -gt "0" ]; then | |
| echo "✗ Found workflows other than test-actions.yml" | |
| echo " Marketplace actions cannot contain workflow files" | |
| find .github/workflows -name "*.yml" ! -name "test-actions.yml" | |
| exit 1 | |
| fi | |
| echo "✓ No conflicting workflows found!" | |
| - name: Verify required files | |
| run: | | |
| echo "Checking required files..." | |
| [ -f "action.yml" ] || { echo "✗ Missing action.yml"; exit 1; } | |
| echo "✓ All required files present!" | |
| - name: Validate YAML syntax | |
| run: | | |
| echo "Validating YAML syntax..." | |
| # Install yq for YAML validation | |
| sudo wget -qO /usr/local/bin/yq https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 | |
| sudo chmod +x /usr/local/bin/yq | |
| # Validate root action | |
| yq eval '.' action.yml > /dev/null || { echo "✗ Invalid YAML in action.yml"; exit 1; } | |
| # Validate all composite actions | |
| for action in .github/actions/*/action.yml; do | |
| yq eval '.' "$action" > /dev/null || { echo "✗ Invalid YAML in $action"; exit 1; } | |
| done | |
| # Validate test workflow | |
| yq eval '.' .github/workflows/test-actions.yml > /dev/null || { echo "✗ Invalid YAML in test-actions.yml"; exit 1; } | |
| echo "✓ All YAML files valid!" |