Skip to content

Add new workflow for detecting changes in dot org #30

Add new workflow for detecting changes in dot org

Add new workflow for detecting changes in dot org #30

Workflow file for this run

name: Detect changes in documentation within nginx/nginx.org
on:
pull_request:
# workflow_dispatch:
# schedule:
# - cron: "0 */23 * * *"
permissions:
pull-requests: write
env:
FEATURE_BRANCH_NAME: nginx-module-ref-auto-update
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: 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: Check 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: |
git branch ${{ env.FEATURE_BRANCH_NAME }}
git checkout ${{ env.FEATURE_BRANCH_NAME }}
echo "DUMMY" >> new-file.txt
git commit -m "chore: Update NGINX Module reference from detected changes in nginx/nginx.org repo"
git push origin ${{ env.FEATURE_BRANCH_NAME }}
create-PR:
name: Create PR in documentation repository
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: '${{ env.FEATURE_BRANCH_NAME }}',
base: 'main',
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']
});