Skip to content

Swamp's Menu revamp #37

Swamp's Menu revamp

Swamp's Menu revamp #37

Workflow file for this run

name: Typescript Compile and Tests
on:
# This event type is dangerous
pull_request_target:
types: [opened, reopened, synchronize]
paths:
- 'src/**.ts'
branches:
- 'master'
jobs:
Typescript_Compile_and_Tests:
# Ensure the PR is not from a fork
if: github.event.pull_request.head.repo.full_name == github.repository
# PR is from the base repository, so it is only running code that was added by someone with write access, so it's trusted
runs-on: ubuntu-latest
env:
# for some reason this isn't the bot ID, it's some other random number
FISH_BOT_ACTOR_ID: 196413533
permissions:
contents: write
steps:
# Create a token that can be used to push commits
- uses: actions/create-github-app-token@v1
id: generate-token
with:
app-id: ${{ secrets.FISH_BOT_ID }}
private-key: ${{ secrets.FISH_BOT_PRIVATE_KEY }}
# Checkout the trusted code
- uses: actions/checkout@v1
with:
ref: ${{ github.head_ref }}
- name: Git Config
run: |
git config --global core.autocrlf true
git config --global user.name 'github-actions[bot]'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${{ steps.generate-token.outputs.token }}@github.com/${{ github.repository }}
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: true
- name: Typescript Compile
# Only run this if the commit wasn't created by the fish bot
# If it was, this check has already been completed
if: github.actor_id != env.FISH_BOT_ACTOR_ID
run: pnpm run build
- name: Check for modified files in build directory
id: git-check
# Returns 0 if files changed, and 1 if no files changed
run: |
git add build/scripts
echo "committed=$(git commit -m "Automated TypeScript compile" > /dev/null; echo $?)" >> $GITHUB_OUTPUT
- name: Push changes
# Do not create an infinite loop of workflows
if: github.actor_id != env.FISH_BOT_ACTOR_ID && steps.git-check.outputs.committed == '0'
run: git push
- name: Run Tests
if: github.actor_id == env.FISH_BOT_ACTOR_ID || steps.git-check.outputs.committed != '0'
run: pnpm run test