Skip to content
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

Automatically update protos #1027

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions .github/workflows/update-protobufs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Update Protobufs
on:
push:
branches:
- yaakov/auto-protos # temporary trigger during development
#schedule:
#- cron: '0 17 * * SUN'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just dropping a comment for this to be uncommented once we're ready to merge.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can also add workflow_dispatch: to be able to manually trigger this from UI.


jobs:
update-protobufs:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/[email protected]

- name: Fetch latest protobufs
run: |
yaakov-h marked this conversation as resolved.
Show resolved Hide resolved
git config pull.ff only
git submodule update --init --recursive
( cd Resources/Protobufs && git pull origin master )

- name: Regenerate C# Code
shell: pwsh
run: |
Resources/ProtobufGen/generate-all.ps1

# TODO: We need a new GitHub Machine Account (or maybe an existing one?) to generate a PAT that we can use as the token here
# otherwise, our new changes will not trigger further Actions (on:push or on:pull_request, i.e. CI/CD builds).
#- name: Create Pull Request
# uses: peter-evans/[email protected]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't played with GH actions much - but what does security look like for a third-party action that is fed a PAT?

Does pinning the action to a specific version guarantee it to be immutable?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that we have a machine account around (I definitely don't have one), so we'll want to create one - and share creds among the core team?

The PAT will definitely need to be limited in scope to just creating PRs, if that's doable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can provide a full commit hash as the version afaik.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be that pull requests created when run by cron shouldn't require a PAT.

Note: If you want pull requests created by this action to trigger an on: push or on: pull_request workflow then you cannot use the default GITHUB_TOKEN.

FWIW, adding permissions section is worthwhile:
contents: write
pull-requests: write

# with:
# #token: ${{ secrets.PAT }}
# commit-message: Update protobufs
# title: Update protobufs
# body: |
# - Update protobufs
# branch: auto/protobufs
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Configure branch-suffix as well? Not sure what happens if the branch already exists and this action tries to create it again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commit all changes to a new branch, or update an existing pull request branch.

It should update the existing branch, which is good, there's no reason to spam branches/prs for each update.

2 changes: 1 addition & 1 deletion Resources/ProtobufGen/generate-all.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ param([string[]]$ProtoDir)

$ProtoGenSrc = Join-Path $PSScriptRoot 'ProtobufGen'
$ProtoGenDll = Join-Path $ProtoGenSrc '\bin\Debug\ProtobufGen.dll'
$ProtoBase = Join-Path $PSScriptRoot '..\ProtoBufs'
$ProtoBase = Join-Path $PSScriptRoot '..\Protobufs'
$SK2Base = Join-Path $PSScriptRoot '..\..\SteamKit2\SteamKit2\Base\Generated'

& dotnet build --configuration Debug $ProtoGenSrc
Expand Down