Initial commit #1
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: TestSim - Build Site | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
name: Rebuild Site | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
with: | |
lfs: true | |
# Ideally this makes the next step run faster | |
# But I haven't noticed a speed difference | |
# May want to cache the ./node_modules directory directly... | |
- name: Cache Node Modules | |
uses: actions/cache@v2 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- name: Install Node Modules | |
run: npm install | |
# Switching the HTML entrypoint over to the build | |
- name: Pre-Process Site | |
run: | | |
sed -e 's/\/src\//\/build\//g' index.html > index.html.tmp | |
mv index.html.tmp index.html | |
- name: Run esbuild | |
run: npm run build | |
- name: Commit the Updated Build Artifacts | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Actions" | |
git add build | |
git add index.html | |
git diff-index --quiet HEAD || git commit -m "Rebuild Site" | |
# Force Push from main to gh-pages... | |
# This means there is no history being accumulated | |
- name: Push Changes to branch | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: gh-pages | |
force: true |