-
Notifications
You must be signed in to change notification settings - Fork 592
Auto update DLLs #3007
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
bfops
wants to merge
2
commits into
master
Choose a base branch
from
bfops/auto-update-DLLs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Auto update DLLs #3007
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,90 @@ | ||
name: Sync DLLs to C#/Unity SDK | ||
|
||
on: | ||
push: | ||
branches: [master] # Triggers on new commits to master | ||
workflow_dispatch: | ||
inputs: | ||
github_ref: | ||
description: 'Ref to generate DLLs from (defaults to master)' | ||
required: false | ||
default: '' | ||
|
||
jobs: | ||
sync: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Set up GitHub CLI | ||
uses: actions/setup-gh@v4 | ||
|
||
- name: Authenticate GitHub CLI | ||
run: gh auth login --with-token <<< "${{secrets.UNITY_SDK_TOKEN}}" | ||
|
||
- name: Set SpacetimeDB ref | ||
run: | | ||
echo "SPACETIMEDB_REF=${{ github.event.inputs.github_ref || 'master' }}" >> $GITHUB_ENV | ||
|
||
- name: Checkout SpacetimeDB | ||
uses: actions/checkout@v4 | ||
with: | ||
path: SpacetimeDB | ||
ref: ${{ env.SPACETIMEDB_REF }} | ||
|
||
- name: Set SpacetimeDB sha | ||
run: | | ||
cd SpacetimeDB | ||
echo "SPACETIMEDB_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Checkout C#/Unity SDK | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: clockworklabs/com.clockworklabs.spacetimedbsdk | ||
token: ${{secrets.UNITY_SDK_TOKEN}} | ||
path: com.clockworklabs.spacetimedbsdk | ||
|
||
- name: Update DLLs | ||
run: | | ||
cd SpacetimeDB/crates/bindings-csharp | ||
dotnet pack | ||
|
||
- name: Copy DLLs | ||
run: | | ||
cd com.clockworklabs.spacetimedbsdk | ||
git checkout -B bot/update-dlls origin/master | ||
bash tools~/write-nuget-config.sh ../SpacetimeDB | ||
dotnet restore | ||
|
||
- name: Update .meta files | ||
run: | | ||
cd com.clockworklabs.spacetimedbsdk/packages | ||
# find any new untracked directories, which indicate that we've imported a new version of the DLLs | ||
NEW_DIR="$(cd spacetimedb.bsatn.runtime && git ls-files --others --exclude-standard . | cut -d'/' -f1 | sort -u)" | ||
if test -z "${NEW_DIR}"; then | ||
echo "No meta files to update" | ||
else | ||
OLD_DIR="$(cd spacetimedb.bsatn.runtime && git ls-files . | cut -d'/' -f1 | sort -u)" | ||
for file in $(find . -name '*.meta'); do | ||
mv "$file" "${file/$OLD_DIR/$NEW_DIR}"; | ||
done | ||
rm -rf "$OLD_DIR" | ||
fi | ||
|
||
- name: Commit Changes | ||
run: | | ||
cd com.clockworklabs.spacetimedbsdk/packages | ||
git add . | ||
git commit -m "Update DLLs from SpacetimeDB commit $SPACETIMEDB_SHA" || echo "No changes to commit" | ||
git push -u origin bot/update-dlls | ||
|
||
- name: Create or update PR | ||
env: | ||
GH_TOKEN: ${{ secrets.UNITY_SDK_TOKEN }} | ||
run: | | ||
cd com.clockworklabs.spacetimedbsdk/packages | ||
gh pr create --title 'Update DLLs' --base master --head bot/update-dlls || echo 'PR already exists' | ||
gh pr edit bot/update-dlls --body-file - <<EOF | ||
This automated PR updates our DLLs. | ||
|
||
Triggered by commit: https://github.com/${{ github.repository }}/commit/${SPACETIMEDB_SHA} | ||
EOF | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Copilot Autofix
AI 20 days ago
To fix the issue, add a
permissions
block at the root of the workflow file to explicitly define the least privileges required for the workflow. Based on the actions performed in the workflow, the following permissions are necessary:contents: read
for reading repository contents.pull-requests: write
for creating and updating pull requests.This ensures that the workflow has only the permissions it needs to complete its tasks, reducing the risk of unauthorized actions.