App-GHGen

 view release on metacpan or  search on metacpan

action.yml  view on Meta::CPAN

        fi
        
        echo "$output"
        
        # Extract metrics
        issues=$(echo "$output" | grep "Total issues found:" | awk '{print $NF}')
        fixes=$(echo "$output" | grep "Fixes applied:" | awk '{print $NF}')
        
        echo "issues=${issues:-0}" >> $GITHUB_OUTPUT
        echo "fixes=${fixes:-0}" >> $GITHUB_OUTPUT
        
        # Save full output for commenting
        echo "$output" > /tmp/ghgen-analysis.txt
        
        exit 0  # Don't fail the action if issues found
    
    - name: Generate comment
      if: github.event_name == 'pull_request' && inputs.mode == 'comment'
      id: generate-comment
      shell: bash
      run: |
        cat > /tmp/comment.md << 'EOF'
        ## 🔍 GHGen Workflow Analysis
        
        EOF
        
        # Add analysis results
        if [ -f /tmp/ghgen-analysis.txt ]; then
          echo '```' >> /tmp/comment.md
          cat /tmp/ghgen-analysis.txt >> /tmp/comment.md
          echo '```' >> /tmp/comment.md
        fi
        
        # Add recommendations
        issues=${{ steps.analyze.outputs.issues }}
        if [ "$issues" -gt 0 ]; then
          cat >> /tmp/comment.md << 'EOF'
        
        ### 💡 Recommendations
        
        Run `ghgen analyze --fix` locally to automatically apply these fixes, or enable auto-fix mode in this action:
        
        ```yaml
        - uses: nigelhorne/App-GHGen@v5
          with:
            auto-fix: true
        ```
        
        EOF
        fi
        
        cat /tmp/comment.md
    
    - name: Comment on PR
      if: github.event_name == 'pull_request' && inputs.mode == 'comment' && steps.analyze.outputs.issues > 0
      id: comment
      uses: actions/github-script@v8
      with:
        github-token: ${{ inputs.github-token }}
        script: |
          const fs = require('fs');
          const comment = fs.readFileSync('/tmp/comment.md', 'utf8');
          
          const { data } = await github.rest.issues.createComment({
            owner: context.repo.owner,
            repo: context.repo.repo,
            issue_number: context.issue.number,
            body: comment
          });
          
          core.setOutput('url', data.html_url);
          return data.html_url;
    
    - name: Create PR with fixes
      if: inputs.create-pr == 'true' && steps.analyze.outputs.fixes > 0
      uses: peter-evans/create-pull-request@v8
      with:
        token: ${{ inputs.github-token }}
        commit-message: 'chore: optimize GitHub Actions workflows'
        title: '🤖 Optimize GitHub Actions workflows'
        body: |
          ## Automated Workflow Optimization
          
          This PR was automatically created by GHGen to optimize your GitHub Actions workflows.
          
          ### Changes Applied
          
          - ✅ Updated action versions to latest
          - ✅ Added dependency caching
          - ✅ Added security permissions
          - ✅ Added concurrency controls
          - ✅ Optimized workflow triggers
          
          ### Fixes Applied: ${{ steps.analyze.outputs.fixes }}
          
          Please review these changes and merge if they look good!
          
          ---
          *Generated by [GHGen](https://github.com/nigelhorne/App-GHGen)*
        branch: ghgen-optimize-workflows
        delete-branch: true
        labels: |
          automation
          github-actions
          optimization



( run in 0.552 second using v1.01-cache-2.11-cpan-d7a12ab2c7f )