2022-08-19 11:04:08 +03:00
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests
name : Build
on :
push :
branches : [ "main" ]
pull_request :
branches : [ "main" ]
2023-02-13 16:46:54 +03:00
release :
types :
- published
permissions :
contents : write
2022-08-19 11:04:08 +03:00
jobs :
build-and-test :
name : Build zui
env :
CI : ""
runs-on : ubuntu-latest
strategy :
matrix :
node-version : [ 16. x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
steps :
- name : Checkout repository
2023-02-13 16:46:54 +03:00
uses : actions/checkout@v3
2022-08-19 11:04:08 +03:00
with :
fetch-depth : 2
- name : Set up Node.js ${{ matrix.node-version }}
2023-02-13 16:46:54 +03:00
uses : actions/setup-node@v3
2022-08-19 11:04:08 +03:00
with :
node-version : ${{ matrix.node-version }}
2023-02-13 16:46:54 +03:00
cache : 'npm'
2022-08-19 11:04:08 +03:00
- name : Install dependencies
run : npm install
- name : Build app
run : npm run build
2023-02-13 16:46:54 +03:00
- name : Package app
run : tar -czvf /tmp/zui.tgz ./build
- name : Publish artifacts on releases
if : github.event_name == 'release' && github.event.action == 'published'
uses : svenstaro/upload-release-action@v2
with :
repo_token : ${{ secrets.GITHUB_TOKEN }}
file : /tmp/zui.tgz
tag : ${{ github.ref }}
overwrite : true
2023-02-27 16:47:58 +03:00
- name : Generate commit sha
if : github.ref_name == 'main'
uses : benjlevesque/short-sha@v2.1
# This creates and environment variable SHA containing the short commit ID
- name : Create new tag for builds on main branch
if : github.ref_name == 'main'
uses : mathieudutour/github-tag-action@v6.1
with :
custom_tag : commit-${{ env.SHA }}
tag_prefix : ""
github_token : ${{ secrets.GITHUB_TOKEN }}
- name : Publish artifact for builds on main branch
if : github.ref_name == 'main'
uses : svenstaro/upload-release-action@v2
with :
repo_token : ${{ secrets.GITHUB_TOKEN }}
file : /tmp/zui.tgz
tag : commit-${{ env.SHA }}
prerelease : true # Mark as prerelease and avoid triggering another workflow for the new tag
overwrite : true