-
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
base: master
Are you sure you want to change the base?
Auto update DLLs #3007
Conversation
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 |
Check warning
Code scanning / CodeQL
Workflow does not contain permissions Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 19 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.
-
Copy modified lines R13-R16
@@ -12,2 +12,6 @@ | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
jobs: |
Description of Changes
API and ABI breaking changes
Expected complexity level and risk
Testing