Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[No QA][HelpDot] Enforce adding of a redirect if an article is rename/moved/deleted. #42954

Merged
merged 37 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
1c33fe5
add step to enforce redirect
rushatgabhane May 31, 2024
ff891d8
continue if failed
rushatgabhane May 31, 2024
e7ed45e
add base to check diff
rushatgabhane May 31, 2024
074ad97
add articles dir
rushatgabhane May 31, 2024
124ed24
rename
rushatgabhane May 31, 2024
32c0387
delete article
rushatgabhane May 31, 2024
21ad4cb
get aricle dir diff with status
rushatgabhane May 31, 2024
b6ffc13
add \n for format
rushatgabhane May 31, 2024
6151124
add fake redirect changes
rushatgabhane May 31, 2024
d22cbb3
add r trips
rushatgabhane May 31, 2024
7e8028c
detect if article moved / deletecd
rushatgabhane May 31, 2024
a403ac1
working grep to detect rename / delete / modified
rushatgabhane May 31, 2024
4937921
add err messages and fail on error
rushatgabhane May 31, 2024
71760b5
use vars
rushatgabhane May 31, 2024
927d1dc
Update redirects.csv
rushatgabhane Jun 2, 2024
98bf939
Rename Add-an-expense-rename.md to Add-an-expense.md
rushatgabhane Jun 2, 2024
d0ba455
Revert "delete article"
rushatgabhane Jun 2, 2024
98cfa67
fix lint
rushatgabhane Jun 2, 2024
e82dcbd
del
rushatgabhane Jun 2, 2024
b0ada87
add enforce redirect
rushatgabhane Jun 2, 2024
74562f4
Rename Add-expenses-in-bulk.md to Rename-Add-expenses-in-bulk.md
rushatgabhane Jun 2, 2024
944599c
Update enforceRedirect.sh
rushatgabhane Jun 2, 2024
b98acb9
add env var for branch
rushatgabhane Jun 2, 2024
9f5ccf5
add env var for branch
rushatgabhane Jun 2, 2024
de92671
fetch depth 0
rushatgabhane Jun 2, 2024
e3e8906
fetch depth 0
rushatgabhane Jun 2, 2024
4db1f3d
add logs
rushatgabhane Jun 2, 2024
0cf71db
refactor conditional
rushatgabhane Jun 2, 2024
b267c1d
quite mode
rushatgabhane Jun 2, 2024
e037ab0
quite mode
rushatgabhane Jun 2, 2024
e5a95ff
fix condition
rushatgabhane Jun 2, 2024
95ba3d2
Update redirects.csv
rushatgabhane Jun 2, 2024
20853b9
fix condition
rushatgabhane Jun 2, 2024
ce0465c
Merge branch 'help-redirect' of github.com:rushatgabhane/exfy into he…
rushatgabhane Jun 2, 2024
a2b7917
fix condition
rushatgabhane Jun 2, 2024
d8e49db
rm redirect
rushatgabhane Jun 2, 2024
298b8ba
undo rename
rushatgabhane Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading