Merge pull request #904 from Shopify/cd/app-bridge-react-bump #163
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create Javascript conversion PR | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
convert-ts-files: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v2 | |
- name: Create lock file | |
run: touch yarn.lock | |
- name: Setup Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.20.x | |
cache: 'yarn' | |
- name: Install dependencies | |
run: yarn add -W --dev @shopify/eslint-plugin --ignore-engines | |
- name: Create temporary tsconfig file | |
run: | | |
echo '{ | |
"include": ["./app/**/*", "*.ts", "*.tsx", ".graphqlrc.ts"], | |
"compilerOptions": { | |
"strict": true, | |
"removeComments": false, | |
"skipLibCheck": true, | |
"isolatedModules": true, | |
"noEmitOnError": true, | |
"jsx": "preserve", | |
"module": "ES2022", | |
"moduleResolution": "bundler", | |
"target": "ES2022", | |
"paths": { | |
"~/*": ["./app/*"] | |
} | |
} | |
}' > tsconfig.js.json | |
- name: Transpile to Javascript | |
run: yarn tsc -p tsconfig.js.json | |
- name: Remove Typescript files | |
run: | | |
find app \( -name "*.ts" -o -name "*.tsx" \) -delete | |
find . \( -name ".graphqlrc.ts" -o -name "tsconfig.js.json" -o -name "vite.config.ts" \) -delete | |
- name: Run prettier | |
run: yarn prettier -w "app/**/*.{js,jsx}" ".graphqlrc.js" "vite.config.js" | |
- name: Run ESLint | |
run: | | |
yarn lint "app/**/*.{js,jsx}" ".graphqlrc.js" "vite.config.js" --fix --no-cache --ignore-pattern "\!.graphqlrc.js" --plugin @shopify/eslint-plugin --rule '{ | |
"import/order": "error", | |
"import/newline-after-import": "error", | |
"padding-line-between-statements": ["error", | |
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*"}, | |
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]} | |
{ "blankLine": "always", "prev": "*", "next": "return" }, | |
{ "blankLine": "always", "prev": "*", "next": "export" }, | |
{ "blankLine": "never", "prev": "export", "next": "export" }, | |
{ "blankLine": "always", "prev": "*", "next": "block-like" }, | |
{ "blankLine": "always", "prev": "block-like", "next": "*" } | |
]}' | |
- name: Prepare files for git | |
run: | | |
git config user.name GitHub | |
git config user.email [email protected] | |
git fetch | |
git restore --staged package.json | |
git restore package.json | |
- name: Stage changes to files | |
run: | | |
git add . | |
git checkout -b temp_javascript_updates | |
git commit -m "Convert template to Javascript" | |
git checkout javascript | |
git pull | |
git checkout - | |
git rebase -m -X theirs javascript | |
git push -f origin temp_javascript_updates:javascript_updates | |
- name: Create Javascript PR | |
run: | | |
gh pr view --json mergedAt -q ".mergedAt" javascript_updates | grep -E "^$" || \ | |
gh pr create -B javascript -H javascript_updates --title 'Convert template to Javascript' --body 'This is an automated PR that converts the latest changes from Typescript to Javascript' | |
env: | |
GH_TOKEN: ${{ github.token }} |