This action is designed to convert JavaScript files with the .jsx extension in a pull request, on the main branch to TypeScript.
This action uses the convert-js-to-ts package to convert the JavaScript files to TypeScript. The package is also available on npm.
This action is triggered by a pull request on the main branch. The action will switch to the Pull Request source branch and convert the JavaScript files to TypeScript and store the generated typescript files in the src/output directory. It will then run a test using the default react test (react-scripts test) and if the test passes it will push the changes to the main branch as an added commit on the pull request. It will then comment on the pull request that the JavaScript files have been converted and assign a reviewer to review the changes.
-
The Pull Request must have the label convert-to-ts attached to it.
-
This action assumes you have a main branch in your repository and a src directory in your pull request.
-
The action only converts the JavaScript files located within the src directory of the changes in the pull request.
-
You can use this project to update a podcast feed located within this repository in the ./output/podcast.xml file or update other podcast feeds in other repositories. When you use another repo to run the project, it will find the action.yml file, understand that it needs to use the Docker image, run the Dockerfile to generate the server then run the entrypoint, which will set up git, run feed.py and push the code to the server and in so doing generate your feed.
In your repository got to Actions and select set up a workflow yourself.
Create a YAML file named main.yml with the following format:
on:
pull_request:
branches: [main]
types: [labeled]
jobs:
convert-test-review:
if: contains(github.event.pull_request.labels.*.name, 'convert-to-ts')
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Run Converter
uses: Kmtengo/automated-js-ts-converter@main
Note
Ensure to grant the entrypoint.sh file executable permissions by running the command chmod -R 775 entrypoint.sh
in the terminal.
Run ls -la
to ensure that it has been granted the necessary permissions.