Build /tg/ui #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
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 }} | |
- 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 | |
tgui_yarn_cache_dir=$(cd tgui ; yarn config get cacheFolder) | |
if [ -n $tgui_yarn_cache_dir ] && [ $tgui_yarn_cache_dir != 'undefined' ] ; then | |
echo 'TGUI_YARN_CACHE_DIR='"$(tgui_yarn_cache_dir)" >> "$GITHUB_ENV" | |
fi | |
- name: Cache Dependencies | |
uses: actions/cache@v3 | |
with: | |
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} | |
path: | | |
**/node_modules | |
${{ env.TGUI_YARN_CACHE_DIR }} | |
- name: Update Branch | |
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 --unshallow origin @ | |
git fetch origin master && { 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/packages/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 18 | |
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 ./tgui/packages/tgui/public/ | |
git commit -m "Build and update tgui" | |
git push | |
fi |