Sorry for the poor wording in the title. Essentially, I have a website with Typescript (not Node) that I want to host via Github Pages. I have a tsconfig.json
that essentially looks like this:
{
"compilerOptions": {
"rootDir": "./src",
"outDir": "./js"
},
"include": ["./src"]
}
I don't want my compiled code on the main branch, so my gitignore contains
js/
In order to have my project work on Github Pages, I set up action-build-typescript to compile my Typescript onto a separate branch, which would be the source for Github pages.
on:
push:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3
- name: Build and push
uses: alexthemaster/action-build-typescript@master
with:
pushToBranch: true
branch: "gh-pages"
githubToken: ${{ secrets.GITHUB_TOKEN }}
This works great, however the js/
directory wasn't being created. Some digging revealed that when this action was pushing to the gh-pages
branch, the .gitignore
was still being applied, thus my Javascript wasn't being committed.
Is there a better way I can do this? Should I just push my compiled code to main
?
If you add a commit to the gh-pages
branch that removes (or comments out) this line in the .gitignore
file, the files will be added in commits on this branch.
Perhaps you have to checkout the gh-pages branch and merge from the source branch first, so that the .gitignore file from the gh-pages branch is used for the commit.
Alternative:
Remove the line from the .gitignore
file before the build and push step. To achieve this, you can just overwrite it with a prepared .gitignore-pages
file in your source branch. The changed .gitignore file will be committed to the gh-pages
branch, but since you probably will never merge ist back to your source branch, this will be no problem.