Analyze FreeCAD Addons #18
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: Analyze FreeCAD Addons | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| # Run daily at 05:23 UTC | |
| - cron: "23 5 * * *" | |
| permissions: | |
| contents: write | |
| jobs: | |
| analyze: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 # Update to latest if available | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 # Update to latest if available | |
| with: | |
| version: "latest" | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 # Update to latest if available | |
| with: | |
| python-version: "3.11" | |
| - name: Install git (required for cloning addons) | |
| run: sudo apt-get update && sudo apt-get install -y git | |
| - name: Run analysis | |
| run: uv run analyze | |
| - name: Get current date | |
| id: date | |
| run: echo "date=$(date +'%Y-%m-%d')" >> "$GITHUB_OUTPUT" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 # Update to latest if available | |
| with: | |
| tag_name: report-${{ steps.date.outputs.date }} | |
| name: Addons Report ${{ steps.date.outputs.date }} | |
| body: | | |
| Automated FreeCAD Addons analysis report generated on ${{ steps.date.outputs.date }}. | |
| files: output/* | |
| fail_on_unmatched_files: false | |
| - name: Deploy reports to gh-pages | |
| run: | | |
| # Copy output to a temporary location | |
| mkdir /tmp/reports | |
| cp -a output/. /tmp/reports/ | |
| # Switch to gh-pages branch | |
| git fetch origin gh-pages:gh-pages | |
| git checkout gh-pages | |
| # Copy reports from temp to root | |
| cp -a /tmp/reports/. . | |
| # Copy the newest report-*.html to index.html | |
| newest_report=$(ls -r -1 report-*.html 2>/dev/null | head -n1) | |
| if [ -n "$newest_report" ]; then | |
| # Determine if the report is from the first day of the month | |
| day_of_month=$(basename "$newest_report" .html | sed 's/^report-//' | cut -d'-' -f3) | |
| day_of_month=${day_of_month:-01} | |
| if [ "$day_of_month" = "01" ]; then | |
| cp "$newest_report" index.html | |
| else | |
| mv "$newest_report" index.html | |
| fi | |
| fi | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git add . | |
| git commit -m "Update reports and index.html [skip ci]" || echo "No changes to commit." | |
| git push origin gh-pages |