-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: game bridge build workflow (#1956)
- Loading branch information
1 parent
f3dc834
commit e1749d3
Showing
3 changed files
with
231 additions
and
13 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -x | ||
|
||
USER=$1 | ||
|
||
response=$(gh api \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
"/orgs/immutable/teams/sdk/memberships/${USER}") | ||
|
||
echo "$response" | ||
|
||
if echo "$response" | grep -q '"state":"active"'; then | ||
IS_MEMBER=true | ||
else | ||
IS_MEMBER=false | ||
fi | ||
echo "$IS_MEMBER" | ||
|
||
# Set the environment variable for the GitHub workflow | ||
echo "IS_MEMBER=$IS_MEMBER" >> "$GITHUB_ENV" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
# Workflow to manually trigger a build of the game bridge with the selected SDK tag | ||
# and create a PR with the changes to the game SDK repository. | ||
|
||
name: Build Game Bridge | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
ts_sdk_tag: | ||
type: string | ||
description: TS SDK version tag | ||
required: true | ||
game_engine: | ||
type: choice | ||
description: Game SDK to update | ||
options: | ||
- Unity | ||
# - Unreal | ||
# - Both | ||
required: true | ||
default: Unity | ||
dry_run: | ||
type: boolean | ||
description: "(Optional) Dry run" | ||
required: false | ||
default: false | ||
|
||
env: | ||
TS_SDK_TAG: ${{ github.event.inputs.ts_sdk_tag }} | ||
GAME_ENGINE: ${{ github.event.inputs.game_engine }} | ||
DRY_RUN: ${{ github.event.inputs.dry_run }} | ||
GH_TOKEN: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build-game-bridge: | ||
name: Build Game Bridge | ||
runs-on: ubuntu-latest-4-cores | ||
env: | ||
NODE_OPTIONS: --max-old-space-size=14366 | ||
steps: | ||
- name: Checkout SDK Repository | ||
id: checkout-sdk | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: "${{ env.TS_SDK_TAG }}" | ||
fetch-depth: 0 | ||
|
||
# uncomment when the script it merged and tagged | ||
# - name: Check SDK Team Membership | ||
# id: check_team | ||
# run: | | ||
# ./.github/scripts/check-team-membership.sh "${{ github.actor }}" "${{ env.GH_TOKEN }}" | ||
# source "$GITHUB_ENV" | ||
# echo "${{ github.actor }} is a member of the SDK team: $IS_MEMBER" | ||
# if [[ "$IS_MEMBER" != "true" ]]; then | ||
# echo "Not a member of the SDK team, exiting workflow" | ||
# exit 1 | ||
# fi | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: ".nvmrc" | ||
registry-url: https://registry.npmjs.org/ | ||
cache: "yarn" | ||
|
||
- name: Restore cached node_modules | ||
id: restore-cache-node_modules | ||
uses: actions/cache@v4 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-build-cache-deps-${{ hashFiles('yarn.lock') }} | ||
|
||
- name: Install dependencies | ||
if: steps.restore-cache-node_modules.outputs.cache-hit != 'true' | ||
run: yarn install --immutable | ||
|
||
- name: Set TS SDK hash | ||
run: echo "TS_SDK_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Build Game Bridge | ||
run: cd packages/game-bridge && yarn build | ||
|
||
# make artifacs avilable for download | ||
- name: Upload Build Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: game-bridge-artifacts | ||
path: ./packages/game-bridge/dist | ||
|
||
- name: Cache build artifacts | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./packages/game-bridge/dist | ||
key: "${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }}" | ||
|
||
create-unity-pr: | ||
name: Create Unity PR | ||
needs: build-game-bridge | ||
# if: ${{ github.event.inputs.game_engine == 'Unity' || github.event.inputs.game_engine == 'Both' }} | ||
runs-on: ubuntu-latest-4-cores | ||
steps: | ||
- name: Checkout SDK Repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ env.GH_TOKEN }} | ||
ref: "${{ env.TS_SDK_TAG }}" | ||
|
||
- name: Setup Github | ||
run: | | ||
git config --global user.name "${GITHUB_ACTOR}" | ||
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com" | ||
- name: Restore Cached Build Artifacts | ||
id: restore-cache-game-bridge-build | ||
uses: actions/cache@v4 | ||
with: | ||
path: ./packages/game-bridge/dist | ||
key: ${{ runner.os }}-game-bridge-build-${{ env.TS_SDK_TAG }} | ||
|
||
- name: Check Cache Restore | ||
if: steps.restore-cache-game-bridge-build.outputs.cache-hit != 'true' | ||
run: echo "Game Bridge build cache not restored, exiting" && exit 1 | ||
|
||
- name: Checkout Unity SDK Repo | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: immutable/unity-immutable-sdk | ||
token: ${{ env.GH_TOKEN }} | ||
path: unity-immutable-sdk | ||
ref: main | ||
clean: true | ||
fetch-depth: 0 | ||
|
||
- name: Change Unity Branch | ||
run: | | ||
cd unity-immutable-sdk | ||
git checkout -b "chore/update-game-bridge-${{ env.TS_SDK_TAG }}" | ||
cd .. | ||
- name: Copy Game Bridge Build | ||
run: cp -r ./packages/game-bridge/dist/unity/index.html ./unity-immutable-sdk/src/Packages/Passport/Runtime/Resources/index.html | ||
|
||
- name: Commit Changes | ||
run: | | ||
cd unity-immutable-sdk | ||
git add src/Packages/Passport/Runtime/Resources/index.html | ||
git commit -m "chore: update game bridge to ${{ env.TS_SDK_TAG }}" | ||
cd .. | ||
- name: Push Changes | ||
if: ${{ env.DRY_RUN == 'false' }} | ||
run: | | ||
cd unity-immutable-sdk | ||
git push -u origin "chore/update-game-bridge-${{ env.TS_SDK_TAG }}" | ||
cd .. | ||
- name: Create PR (Dry Run) | ||
if: ${{ env.DRY_RUN == 'true' }} | ||
run: | | ||
cd unity-immutable-sdk | ||
echo "gh pr create --base main --head chore/update-game-bridge-${{ env.TS_SDK_TAG }} --title 'chore: update game bridge to ${{ env.TS_SDK_TAG }}' --body 'Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))'" | ||
cd .. | ||
- name: Create PR | ||
if: ${{ env.DRY_RUN == 'false' }} | ||
run: | | ||
cd unity-immutable-sdk | ||
gh pr create --base main --head "chore/update-game-bridge-${{ env.TS_SDK_TAG }}" --title "chore: update game bridge to ${{ env.TS_SDK_TAG }}" --body "Update game bridge (build from ts-immutable-sdk version [${{ env.TS_SDK_TAG }}](https://github.com/immutable/ts-immutable-sdk/releases/tag/${{ env.TS_SDK_TAG }}))" | ||
cd .. | ||
# create-unreal-pr: | ||
# name: Create Unreal PR | ||
# needs: build-game-bridge | ||
# if: ${{ github.event.inputs.game_engine == 'Unreal' || github.event.inputs.game_engine == 'Both' }} | ||
# runs-on: ubuntu-latest-4-cores | ||
# env: | ||
# GH_TOKEN: ${{ secrets.TS_IMMUTABLE_SDK_GITHUB_TOKEN }} | ||
# NODE_OPTIONS: --max-old-space-size=14366 | ||
# steps: | ||
# - name: Checkout SDK Repository | ||
# uses: actions/checkout@v4 | ||
# with: | ||
# ref: "${{ github.event.inputs.ts_sdk_tag }}" |
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