Skip to content

Build /tg/ui

Build /tg/ui #19

Workflow file for this run

name: Build tgui
on:
workflow_dispatch:
inputs:
upstream-repository:
description: The upstream repository.
required: false
type: string
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
env:
REPOSITORY: ${{ vars.DEFAULT_REPOSITORY || inputs.repository }}
UPSTREAM_REPOSITORY: ${{ vars.UPSTREAM_REPOSITORY || inputs.upstream-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 }}
- name: Setup Git User
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "tgui builder"
- name: Install Dependencies
run: |
source ~/.nvm/nvm.sh
nvm install 18
corepack enable
echo "TGUI_YARN_CACHE_DIR=$(cd tgui ; yarn config get cacheFolder)" >> "$GITHUB_ENV"
- name: Cache Dependencies
uses: actions/cache@v3
with:
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }}
path: |
${{ env.TGUI_YARN_CACHE_DIR }}
- name: Try to Fetch Upstream
if: ${{ env.UPSTREAM_REPOSITORY }}
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/$UPSTREAM_REPOSITORY/compare/${UPSTREAM_REPOSITORY%%/*}:master...${REPOSITORY%%/*}:master" \
| jq '.behind_by')
if [ $behind_by -le 0 ] ; then
echo 'No changes to merge. Skipping step.'
exit 0
fi
git fetch --unshallow origin @
git fetch "git@github.com:$UPSTREAM_REPOSITORY.git" master && git merge FETCH_HEAD
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/packages/tgui/public/ ; then
echo 'Automatic merge failed: non-tgui bundle files have conflicts.'
exit 1
fi
- name: Build
run: |
source ~/.nvm/nvm.sh
nvm use 18
cd tgui
bin/tgui
- name: Commit and Push
run: |
if ! git diff --exit-code > /dev/null; then
git add ./tgui/packages/tgui/public/
git commit -m "Build and update tgui"
git push
fi