From dd4cd7ca5b51e9286fb6202ec203e01ed8cd0d7f Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Sat, 28 Dec 2024 10:17:59 +0100 Subject: [PATCH] Try to only trigger build on documentation changes (#4365) * Try to only trigger build on documentation changes --- .github/workflows/netlify.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/netlify.yml diff --git a/.github/workflows/netlify.yml b/.github/workflows/netlify.yml new file mode 100644 index 0000000000..76265586ff --- /dev/null +++ b/.github/workflows/netlify.yml @@ -0,0 +1,33 @@ +name: Deploy documentation to Netlify + +on: + push: + branches: + - main + +jobs: + check-docs-changes: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Check if /docs/ has changes + id: check_docs + run: | + git fetch origin main + changes=$(git diff --name-only HEAD~1 HEAD | grep '^docs/') + if [ -z "$changes" ]; then + echo "No changes in /docs/. Skipping deployment." + echo "deploy=false" >> $GITHUB_ENV + else + echo "Changes detected in /docs/. Proceeding with deployment." + echo "deploy=true" >> $GITHUB_ENV + + - name: Deploy to Netlify + if: steps.check_docs.outputs.deploy == 'true' + env: + NETLIFY_BUILD_HOOK_URL: ${{ secrets.NETLIFY_BUILD_HOOK_URL }} + run: | + curl -X POST -d {} -H "Content-Type: application/json" $NETLIFY_BUILD_HOOK_URL