Skip to content

Merge pull request #3 from Shopify/new-workflow #1

Merge pull request #3 from Shopify/new-workflow

Merge pull request #3 from Shopify/new-workflow #1

Workflow file for this run

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: 16.x
cache: 'yarn'
- name: Install dependencies
run: yarn add -W --dev @shopify/prettier-config @shopify/eslint-plugin --ignore-engines
- name: Transpile to Javascript
run: |
find app \( -name "*.ts" -o -name "*.tsx" \) -exec yarn tsc \
--strict \
--removeComments false \
--skipLibCheck \
--isolatedModules \
--noEmitOnError \
--jsx "preserve" \
--module "ES2022" \
--moduleResolution "bundler" \
--target "ES2022" \
--types "@shopify/app-bridge-types" \
{} +
- name: Remove Typescript files
run: find app \( -name "*.ts" -o -name "*.tsx" \) -delete
- name: Run prettier
run: yarn prettier -w "app/**/*.{js,jsx}" --plugin @shopify/prettier-config
- name: Run ESLint
run: |
yarn lint "app/**/*.{js,jsx}" --fix --no-cache --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: Remove tsc from the build command
run: |
patternToRemove="tsc && "
sedChangesFile=sedchanges.log
sed -i "s/^\( *\"build\": \".*\)$patternToRemove\(.*\)$/\1\2/w $sedChangesFile" package.json
if [ -s $sedChangesFile ]; then rm $sedChangesFile; else echo replacement failed; exit 1; fi
- 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 }}