Skip to content

Commit f9904aa

Browse files
committed
[DXDOCS-129] feat: set up gh action for redirects cleanup
1 parent 8c787fa commit f9904aa

File tree

4 files changed

+44
-1335
lines changed

4 files changed

+44
-1335
lines changed
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Cleanup redirects config file.
2+
name: Redirects cleanup PR
3+
4+
on:
5+
schedule:
6+
- cron: '0 7 * * 1'
7+
workflow_dispatch:
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Get current date
14+
id: date
15+
run: echo "current_date=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
16+
- name: Checkout
17+
uses: actions/checkout@v2
18+
- uses: actions/setup-node@v2
19+
with:
20+
node-version: '14.17'
21+
cache: 'yarn'
22+
- run: yarn
23+
- run: yarn run clean-redirects
24+
- name: Create Pull Request
25+
id: cpr
26+
uses: peter-evans/create-pull-request@v3
27+
with:
28+
commit-message: Redirects config cleanup ${{ env.current_date }}
29+
committer: GitHub <[email protected]>
30+
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
31+
signoff: false
32+
branch: clean_redirects_action_${{ env.current_date }}
33+
delete-branch: true
34+
title: 'Redirects config cleanup ${{ env.current_date }}'

codemods/clean-redirects-config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,5 @@ module.exports = function(fileInfo, api) {
4545
});
4646
const transformedSource = prettyPrint(root);
4747
// keep position and spaces for block comments within the redirect object
48-
return transformedSource.replace(OBJECT_COMMENT_REGEX, (match, group) => `},\n\n\t${group}`);
48+
return transformedSource.replace(OBJECT_COMMENT_REGEX, (match, group) => `},\n\n ${group}`);
4949
}

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"heroku-prebuild": "bash prebuild.sh",
88
"heroku-postbuild": "bash postbuild.sh",
99
"precommit": "lint-staged",
10-
"transform": "node ./node_modules/jscodeshift/bin/jscodeshift.js",
11-
"clean-redirects": "yarn run transform -t codemods/clean-redirects-config.js config/redirects.js"
10+
"clean-redirects": "npx jscodeshift -t codemods/clean-redirects-config.js config/redirects.js"
1211
},
1312
"lint-staged": {
1413
"*.md": "markdownlint"

0 commit comments

Comments
 (0)