Skip to content

Update nvm config

Update nvm config #16

name: Build & Deploy to branch
env:
BUILD_DIR: dist
DEPLOY_BRANCH_POSTFIX: deploy # Configure the destination branch postfix (code on "main" branch will be built and pushed into "main-POSTFIX" branch)
on:
push:
branches: [ trunk ] # Configure the branchs which you want to run this workflow
jobs:
build-push:
name: "Build & Push"
runs-on: ubuntu-latest
steps:
# Checkout source code
- name: Checkout
uses: actions/checkout@v2
# Setup Nodejs
- name: Use Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
# Install dependencies for build process
- name: Install build dependencies
run: npm install
# Build application into BUILD directory
- name: Build application
run: npm run build
# Synchronize & push BUILD directory to deployment branch
- name: Configure Git informations
run: |
git config --global user.name $GITHUB_ACTOR
git config --global user.email [email protected]
- name: Synchronize & push into deployment branch
run: |
GIT_BRANCH=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)
DEPLOY_BRANCH=$GIT_BRANCH-$DEPLOY_BRANCH_POSTFIX
GIT_COMMIT=$(git rev-parse --short HEAD)
mkdir RELEASE
mv .git RELEASE/.git
cd RELEASE
echo "Checking out $DEPLOY_BRANCH"
git checkout -b $DEPLOY_BRANCH
git stash && git stash drop
(git pull --depth 1 origin $DEPLOY_BRANCH --rebase -X theirs --allow-unrelated-histories) || (echo "Deployment branch synced")
mv ./.git ../.git
cd ..
# Push build into the deployment branch
echo "Pushing build $GIT_COMMIT to $DEPLOY_BRANCH"
mv .git $BUILD_DIR/.git
cd $BUILD_DIR
git add -A
git commit -m "Automated build $GIT_COMMIT"
git push origin $DEPLOY_BRANCH
cd ..