Doin' it #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: Build | |
on: | |
workflow_dispatch: | |
inputs: | |
release: | |
description: 'Create a release build' | |
required: false | |
type: boolean | |
push: | |
branches-ignore: | |
- 'build' | |
paths: | |
- '.github/workflows/**' | |
- 'src/**' | |
- 'action.yaml' | |
- 'package-lock.json' | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache node_modules | |
uses: actions/cache@v4 | |
with: | |
path: 'node_modules' | |
key: node-${{ hashFiles('package-lock.json') }} | |
restore-keys: node- | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: Create release build | |
if: ${{ inputs.release }} | |
run: | | |
npm install | |
npm run build | |
env: | |
NODE_ENV: production | |
- name: Create debug build | |
if: ${{ !inputs.release }} | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Github Actions" | |
git fetch origin build | |
git switch build | |
git merge ${GITHUB_REF#refs/heads/} | |
npm install | |
npm run build | |
- name: Push to GitHub | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: '-f ./dist' | |
author_name: 'GitHub Actions' | |
author_email: '[email protected]' | |
message: | | |
:rocket: Build action | |
Co-authored-by: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> |