Skip to content

Commit

Permalink
Merge pull request #42954 from rushatgabhane/help-redirect
Browse files Browse the repository at this point in the history
[No QA][HelpDot] Enforce adding of a redirect if an article is rename/moved/deleted.
  • Loading branch information
grgia authored Jun 12, 2024
2 parents 100df70 + 298b8ba commit 5ec31c9
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/scripts/enforceRedirect.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash

# HelpDot - Whenever an article is moved/renamed/deleted we should verify that
# we have added a redirect link for it in redirects.csv. This ensures that we don't have broken links.

declare -r RED='\033[0;31m'
declare -r GREEN='\033[0;32m'
declare -r NC='\033[0m'

declare -r ARTICLES_DIRECTORY="docs/articles"
declare -r REDIRECTS_FILE="docs/redirects.csv"

hasRenamedOrDeletedArticle=false
hasModifiedRedirect=false

if git log origin/main..HEAD --name-status --pretty=format: $ARTICLES_DIRECTORY | grep -q -E "^(R|D)"
then
echo "Articles have been renamed/moved/deleted"
hasRenamedOrDeletedArticle=true
fi

if git log origin/main..HEAD --name-status --pretty=format: $REDIRECTS_FILE | grep -q -E "^(M)"
then
echo "Redirects.csv has been modified"
hasModifiedRedirect=true
fi

if [[ $hasRenamedOrDeletedArticle == true && $hasModifiedRedirect == false ]]
then
echo -e "${RED}Articles have been renamed or deleted. Please add a redirect link for the old article links in redirects.csv${NC}"
exit 1
fi

echo -e "${GREEN}Articles aren't moved or deleted, or a redirect has been added. Please verify that a redirect has been added for all the files moved or deleted${NC}"
exit 0
6 changes: 6 additions & 0 deletions .github/workflows/deployExpensifyHelp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ jobs:
env:
IS_PR_FROM_FORK: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork }}
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup NodeJS
uses: ./.github/actions/composite/setupNode
Expand All @@ -42,6 +45,9 @@ jobs:
- name: Check for duplicates and cycles in redirects.csv
run: ./.github/scripts/verifyRedirect.sh

- name: Enforce that a redirect link has been created
run: ./.github/scripts/enforceRedirect.sh

- name: Build with Jekyll
uses: actions/jekyll-build-pages@0143c158f4fa0c5dcd99499a5d00859d79f70b0e
with:
Expand Down

0 comments on commit 5ec31c9

Please sign in to comment.