From 05b82787b7039065f54dd675b3b6ed42d56cbd7d Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Fri, 18 Jul 2025 10:03:20 -0700 Subject: [PATCH 1/4] feat: Add new workflow for detecting changes in dot org --- .github/workflows/dot-org-content.yml | 97 +++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 .github/workflows/dot-org-content.yml diff --git a/.github/workflows/dot-org-content.yml b/.github/workflows/dot-org-content.yml new file mode 100644 index 000000000..3208c9873 --- /dev/null +++ b/.github/workflows/dot-org-content.yml @@ -0,0 +1,97 @@ +name: Detect changes in documentation within nginx/nginx.org + +on: + pull_request: + # workflow_dispatch: + # schedule: + # - cron: "0 */23 * * *" +permissions: + pull-requests: write + +jobs: + detect-changes: + name: Detect changes in 'en' docs of nginx/nginx.org + runs-on: ubuntu-latest + outputs: + IS_CHANGES_DETECTED: ${{ steps.check_changes.outputs.changed }} + steps: + - name: Clone the nginx/nginx-org repository + run: | + git clone --depth=2 https://github.com/nginx/nginx.org.git dot-org-repo + - name: Change for changes in xml/en folder + id: check_changes + run: | + cd dot-org-repo + commit1=$(git rev-parse HEAD) + commit2=$(git rev-parse HEAD^) + + if git diff --name-only $commit2 $commit1 | grep '^xml/en/'; then + echo "Changes detected in /en" + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "No changes in /en" + echo "changed=false" >> $GITHUB_OUTPUT + fi + + - name: Execute make target 'make hugo-md' to generate markdown + if: steps.check_changes.outputs.changed == 'true' + run: | + cd dot-org-repo + make module-markdown + + move-generated-files: + name: Move generated markdown files to '/content/nginx' directory + if: needs.detect-changes.outputs.IS_CHANGES_DETECTED + needs: detect-changes + runs-on: ubuntu-latest + steps: + - name: Move the generated folder + run: | + mv dot-org-repo/libxslt-md/ ./content/nginx/ + + close-stale-PRs: + name: Close any related stale PRs + needs: move-generated-files + runs-on: ubuntu-latest + steps: + - name: Check for any stale PRs + id: check-stale-pr + run: | + "PLACEHOLDER" + + - name: Close relevant PR if any exists + if: steps.check-stale-pr.outputs.IS_STALE_FOUND == 'true' + run: | + "PLACEHOLDER" + + + create-PR: + name: Create PR in documentation repository + if: needs.detect-changes.outputs.IS_CHANGES_DETECTED + needs: close-stale-PRs + runs-on: ubuntu-latest + steps: + - name: Generate the PR + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const { repo, owner } = context.repo; + + const result = await github.rest.pulls.create({ + title: 'NGINX Plus - Module Ref: Update content for content/nginx due to detected changes', + owner, + repo, + head: '${{ github.ref_name }}', + base: 'develop', + body: [ + '### Proposed Changes', + 'Updated NGINX Plus docs', + ].join('\n') + }); + + github.rest.issues.addLabels({ + owner, + repo, + issue_number: result.data.number, + labels: ['product/nginx-plus', 'dependencies', 'module-reference'] + }); From cb07a779f561322bb7e132dad6985040e68b84a1 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Mon, 21 Jul 2025 14:22:57 -0700 Subject: [PATCH 2/4] Refactor to use a new dep for making PR --- .github/workflows/dot-org-content.yml | 82 +++++++-------------------- 1 file changed, 20 insertions(+), 62 deletions(-) diff --git a/.github/workflows/dot-org-content.yml b/.github/workflows/dot-org-content.yml index 3208c9873..045c1e542 100644 --- a/.github/workflows/dot-org-content.yml +++ b/.github/workflows/dot-org-content.yml @@ -1,12 +1,12 @@ name: Detect changes in documentation within nginx/nginx.org on: - pull_request: - # workflow_dispatch: - # schedule: - # - cron: "0 */23 * * *" + schedule: + - cron: "0 */23 * * *" permissions: + contents: write pull-requests: write + issues: write jobs: detect-changes: @@ -15,10 +15,14 @@ jobs: outputs: IS_CHANGES_DETECTED: ${{ steps.check_changes.outputs.changed }} steps: + - name: Checkout Repository + uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2 # v4.2.2 + with: + fetch-depth: 0 - name: Clone the nginx/nginx-org repository run: | git clone --depth=2 https://github.com/nginx/nginx.org.git dot-org-repo - - name: Change for changes in xml/en folder + - name: Check for changes in xml/en folder id: check_changes run: | cd dot-org-repo @@ -32,66 +36,20 @@ jobs: echo "No changes in /en" echo "changed=false" >> $GITHUB_OUTPUT fi - - name: Execute make target 'make hugo-md' to generate markdown if: steps.check_changes.outputs.changed == 'true' run: | cd dot-org-repo make module-markdown - - move-generated-files: - name: Move generated markdown files to '/content/nginx' directory - if: needs.detect-changes.outputs.IS_CHANGES_DETECTED - needs: detect-changes - runs-on: ubuntu-latest - steps: - - name: Move the generated folder - run: | - mv dot-org-repo/libxslt-md/ ./content/nginx/ - - close-stale-PRs: - name: Close any related stale PRs - needs: move-generated-files - runs-on: ubuntu-latest - steps: - - name: Check for any stale PRs - id: check-stale-pr - run: | - "PLACEHOLDER" - - - name: Close relevant PR if any exists - if: steps.check-stale-pr.outputs.IS_STALE_FOUND == 'true' - run: | - "PLACEHOLDER" - - - create-PR: - name: Create PR in documentation repository - if: needs.detect-changes.outputs.IS_CHANGES_DETECTED - needs: close-stale-PRs - runs-on: ubuntu-latest - steps: - - name: Generate the PR - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + - name: Create PR + uses: peter-evans/create-pull-request@v7 + if: steps.check_changes.outputs.changed == 'true' with: - script: | - const { repo, owner } = context.repo; - - const result = await github.rest.pulls.create({ - title: 'NGINX Plus - Module Ref: Update content for content/nginx due to detected changes', - owner, - repo, - head: '${{ github.ref_name }}', - base: 'develop', - body: [ - '### Proposed Changes', - 'Updated NGINX Plus docs', - ].join('\n') - }); - - github.rest.issues.addLabels({ - owner, - repo, - issue_number: result.data.number, - labels: ['product/nginx-plus', 'dependencies', 'module-reference'] - }); + commit-message: "chore: Update nginx plus module reference from detected changes in nginx/nginx.org" + labels: product/nginx-plus, dependencies, module-reference + base: main + branch: update-nginx-module-ref + title: 'NGINX Plus - Module Ref: Update content for content/nginx due to detected changes' + body: | + ### Proposed Changes + Updated NGINX Plus docs. From 529f2ae1f151c153e92abc77c5004ee8981da81f Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Wed, 23 Jul 2025 09:48:55 -0700 Subject: [PATCH 3/4] Use better change comparision command to detect changes --- .github/workflows/dot-org-content.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/dot-org-content.yml b/.github/workflows/dot-org-content.yml index 045c1e542..cb2856f73 100644 --- a/.github/workflows/dot-org-content.yml +++ b/.github/workflows/dot-org-content.yml @@ -26,10 +26,8 @@ jobs: id: check_changes run: | cd dot-org-repo - commit1=$(git rev-parse HEAD) - commit2=$(git rev-parse HEAD^) - if git diff --name-only $commit2 $commit1 | grep '^xml/en/'; then + if git whatchanged --since="1 day ago" -- _xml/en/; then echo "Changes detected in /en" echo "changed=true" >> $GITHUB_OUTPUT else From 89bbff55525705e1e080662042be5e940fc1c940 Mon Sep 17 00:00:00 2001 From: Lam Nguyen Date: Mon, 28 Jul 2025 09:31:33 -0700 Subject: [PATCH 4/4] Added paths to git add the generated files + yaml --- .github/workflows/dot-org-content.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/dot-org-content.yml b/.github/workflows/dot-org-content.yml index cb2856f73..653562207 100644 --- a/.github/workflows/dot-org-content.yml +++ b/.github/workflows/dot-org-content.yml @@ -48,6 +48,9 @@ jobs: base: main branch: update-nginx-module-ref title: 'NGINX Plus - Module Ref: Update content for content/nginx due to detected changes' + add-paths: | + dot-org-repo/libxslt-md/ + dot-org-repo/yaml/nginx_api.yaml body: | ### Proposed Changes Updated NGINX Plus docs.