From fc45962feb039a0322a6aecf79e706dc33c691bd Mon Sep 17 00:00:00 2001 From: Mike Woofter <108414937+mongoKart@users.noreply.github.com> Date: Wed, 4 Dec 2024 16:44:01 -0600 Subject: [PATCH] add files --- .github/pull_request_template.md | 17 ++++++++ .github/workflows/add-netlify-links.yml | 58 +++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/pull_request_template.md create mode 100644 .github/workflows/add-netlify-links.yml diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 00000000..0334545d --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,17 @@ +# Pull Request Info + +[PR Reviewing Guidelines](https://github.com/mongodb/docs-golang/blob/master/REVIEWING.md) + +JIRA - + +### Staging Links + + + +## Self-Review Checklist + +- [ ] Is this free of any warnings or errors in the RST? +- [ ] Did you run a spell-check? +- [ ] Did you run a grammar-check? +- [ ] Are all the links working? +- [ ] Are the [facets and meta keywords](https://wiki.corp.mongodb.com/display/DE/Docs+Taxonomy) accurate? diff --git a/.github/workflows/add-netlify-links.yml b/.github/workflows/add-netlify-links.yml new file mode 100644 index 00000000..08b0391b --- /dev/null +++ b/.github/workflows/add-netlify-links.yml @@ -0,0 +1,58 @@ +name: Add Netlify Links To Changed Pages +on: + workflow_call: + pull_request_target: +jobs: + get-pr-changes: + name: Get Changed Files & Update PR Description + runs-on: ubuntu-latest + permissions: + issues: write + contents: write + pull-requests: write + repository-projects: write + steps: + - uses: actions/checkout@v4 + - name: Get Changed Files + id: changed-files + # pin to a specific commit to ensure stability + uses: tj-actions/changed-files@c65cd883420fd2eb864698a825fc4162dd94482c + with: + separator: "," + files: source/** + - name: Build Netlify Links for Changed Pages + id: build_page_links + env: + CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + run: | + new_links="" + base_link='https://deploy-preview-${{ github.event.number }}--mongodb-docs-ruby.netlify.app' + files=$(echo "$CHANGED_FILES" | tr "," "\n") + for file in $files; do + echo "processing ${file}" + if (! grep -s "includes/" <<< "$file") && + (! grep -s "images/" <<< "$file") && + (! grep -s "examples/" <<< "$file"); then + file="${file#source}" + file="${file%.txt}" + filenoslash="${file:1}" + echo "${base_link}${file}" + new_links+="
  • ${filenoslash}
  • " + else + echo "(file skipped)" + fi + done + if [ "$new_links" == "" ]; then + new_links="No pages to preview" + fi + echo "Final new_links string: " + echo "${new_links}" + echo "staging_links=${new_links}" >> "$GITHUB_OUTPUT" + - name: Update the PR Description + uses: MongoCaleb/pr-description-action@master + with: + regex: ".*" + appendContentOnMatchOnly: true + regexFlags: is + content: "\n${{ steps.build_page_links.outputs.staging_links }}\n" + token: ${{ secrets.GITHUB_TOKEN }}