diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index f8253a7..c9861b0 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -4,16 +4,36 @@ on: push: branches: - main - paths: - - 'docs/**' - - 'mkdocs.yml' permissions: contents: write jobs: - deploy: + check-for-docs-changes: + name: Check for Docs Changes runs-on: ubuntu-latest + outputs: + # Output a boolean indicating if any relevant files have changed + docs_changed: ${{ steps.check_files.outputs.any_changed }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Check for changed files in docs folder or mkdocs.yml + id: check_files + uses: tj-actions/changed-files@v40 + with: + files: | + docs/** + mkdocs.yml + + deploy: + name: Deploy MkDocs Site + runs-on: ubuntu-latest + needs: check-for-docs-changes + if: needs.check-for-docs-changes.outputs.docs_changed == 'true' steps: - name: Checkout Code @@ -29,3 +49,5 @@ jobs: - name: Deploy Docs to GitHub Pages run: mkdocs gh-deploy --force --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/webpack.yml b/.github/workflows/webpack.yml index a5d81e0..a28aa68 100644 --- a/.github/workflows/webpack.yml +++ b/.github/workflows/webpack.yml @@ -2,12 +2,30 @@ name: Build distribution with Webpack on: push: - branches: [ "main" ] - paths: - - 'src/**' - - 'webpack.config.js' + branches: + - main jobs: + detect-source-changes: + name: Detect Source Changes + runs-on: ubuntu-latest + outputs: + source_changed: ${{ steps.check_files.outputs.any_changed }} + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }} + + - name: Check for changed files in src or webpack.config.js + id: check_files + uses: tj-actions/changed-files@v40 + with: + files: | + src/** + webpack.config.js + build: name: Build Distribution runs-on: ubuntu-latest @@ -22,7 +40,9 @@ jobs: matrix: node-version: [22.x] - # Checkout Repository + needs: detect-source-changes + if: needs.detect-source-changes.outputs.source_changed == 'true' + steps: - name: Checkout Repository uses: actions/checkout@v4 @@ -42,16 +62,7 @@ jobs: run: | npm run build - - name: Check for file changes - id: checkDiff - run: | - git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT - - # Commit and push all changed files. - # Must only affect files that are listed in "paths-ignore". - name: Commit Distribution Build - # Only run on a main branch push (e.g., pull request merge). - if: github.event_name == 'push' && steps.checkDiff.outputs.changed == 'true' run: | git config --global user.name "${{ env.CI_COMMIT_AUTHOR }}" git config --global user.email "ci_activity@noreply.github.com" diff --git a/docs/index.md b/docs/index.md index 9aa92a0..05e708b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -45,4 +45,3 @@ engage with the community! ⭐ [star on GitHub](https://github.com/DigiLive/mushroom-strategy) and exploring ways to ❤️ [sponsor the project](https://github.com/sponsors/DigiLive) to support its continued development! Your support helps us grow and improve. -