Skip to content

Build /tg/ui

Build /tg/ui #80

Workflow file for this run

name: Build tgui
on:
workflow_dispatch:
inputs:
repository:
description: The repository to check out.
required: false
type: string
branch:
description: The branch in the repository to check out.
required: true
type: string
merge-master:
default: true
description: If checked or set to true, the master branch will be merged into the current branch before building.
required: false
type: boolean
env:
REPOSITORY: ${{ vars.DEFAULT_REPOSITORY || inputs.repository }}
jobs:
build-tgui:
name: Build tgui
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
repository: ${{ env.REPOSITORY }}
ref: ${{ inputs.branch }}
ssh-key: ${{ secrets.REPOSITORY_SSH_KEY }}
token: ${{ secrets.REPOSITORY_TOKEN || github.token }}
- name: Setup Git User
run: |
git config --global user.email ${{ vars.GIT_EMAIL || '41898282+github-actions[bot]@users.noreply.github.com' }}
git config --global user.name ${{ vars.GIT_USERNAME || 'tgui builder' }}
- name: Install Dependencies
id: install-dependencies
run: |
source ~/.nvm/nvm.sh
nvm install 20
echo "NPM_CACHE_DIR=$(npm config get cache)" >> $GITHUB_OUTPUT
echo "NPM_GLOBAL_CACHE_DIR=$(npm config get prefix)/node_modules/" >> $GITHUB_OUTPUT
- name: Cache Dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
path: |
**/node_modules
**/.yarn
${{ steps.install-dependencies.outputs.NPM_CACHE_DIR }}
${{ steps.install-dependencies.outputs.NPM_GLOBAL_CACHE_DIR }}
- name: Update Branch
if: ${{ inputs.merge-master }}
run: |
behind_by=$(curl -L -s --fail-with-body \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/$REPOSITORY/compare/master...${{ inputs.branch }}" \
| jq '.behind_by')
if [ $behind_by -le 0 ] ; then
echo '- Skipping master merge. No changes to merge.' | tee -a "$GITHUB_STEP_SUMMARY"
exit 0
else
echo '- Merging master branch. HEAD branch is behind by '"$behind_by"' commits.' | tee -a "$GITHUB_STEP_SUMMARY"
fi
git fetch origin master --depth=$behind_by && { git merge FETCH_HEAD || true ; }
exit_code=0
merge_conflicts=$(git diff --name-only --diff-filter=U --exit-code) || exit_code=$?
if [ $exit_code -eq 0 ] ; then
exit 0
elif echo $merge_conflicts | grep -v ^tgui/public/ ; then
echo '- Automatic merge failed. Non-tgui bundle files have conflicts.' | tee -a "$GITHUB_STEP_SUMMARY"
exit 1
fi
- name: Build
run: |
source ~/.nvm/nvm.sh
nvm use 20
cd tgui
bin/tgui
- name: Commit and Push
run: |
if { git update-index --refresh && git diff-index --quiet HEAD -- ; } > /dev/null; then
echo '- Skipping commit. No changes to commit.' | tee -a "$GITHUB_STEP_SUMMARY"
else
git add --all
git commit -m "Build and update tgui"
git push
fi