60 lines
1.5 KiB
YAML
60 lines
1.5 KiB
YAML
name: Build and Save Artifact
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
- dev
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
# Checkout the repository
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v3
|
|
|
|
# Set up Node.js environment
|
|
- name: Set up Node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: '22'
|
|
|
|
# Delete existing build branch
|
|
- name: Delete existing build branch
|
|
run: git branch -d ${GITHUB_REF_NAME}-build || echo "Build branch not found"
|
|
|
|
# Create and switch to build branch
|
|
- name: Create and switch to build branch
|
|
run: git branch ${GITHUB_REF_NAME}-build && git switch ${GITHUB_REF_NAME}-build
|
|
|
|
# Install dependencies
|
|
- name: Install dependencies
|
|
run: npm install
|
|
|
|
# Build the project
|
|
- name: Run npm build
|
|
run: npm run build
|
|
|
|
# Commit build files
|
|
- name: Commit build files to build branch
|
|
uses: actions/checkout@v3
|
|
run: |
|
|
git config --global user.name 'Git Bot'
|
|
git config --global user.email 'noreply@kozelkaricsi.hu'
|
|
git add -f dist && git commit -am 'Build'
|
|
git push
|
|
|
|
# Upload the build directory as an artifact
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: build-artifact
|
|
path: |
|
|
./dist
|
|
./package.json
|