Skip to content
Merged
Changes from all 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
52 changes: 52 additions & 0 deletions .github/workflows/udpate-generated.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'Update Generated Files'

# This workflow is triggered on a schedule (every day at 3:15 AM UTC)
# and can also be triggered manually from the GitHub Actions UI.
on:
workflow_dispatch:
schedule:
- cron: '15 3 * * *'
Comment on lines +5 to +8

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Another option would be to have this fire on every push to main

on:
  push:
    branches:
      - main

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That said, we could also just do this as a check on PRs and require the submitter to do it...

But yeah since you already wrote it this way I'm fine to run with it for now.


jobs:
update-and-pr:
name: 'Update Generated Files and Create PR'
runs-on: ubuntu-latest
container: quay.io/coreos-assembler/fcos-buildroot:testing-devel
steps:
- name: 'Checkout repository'
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 'Mark git directory as safe'
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
shell: bash

- name: 'Install dependencies'
run: ./ci/installdeps.sh
shell: bash

- name: 'Install pandoc'
run: dnf -y install pandoc
shell: bash

- name: 'Update generated docs'
run: cargo xtask update-generated
shell: bash

- name: 'Create Pull Request'

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Based on my read of how the action behaves, it will silently exit if there are no changes detected - https://github.com/peter-evans/create-pull-request?tab=readme-ov-file#action-behaviour

How the action behaves:

  • If there are changes (i.e. a diff exists with the checked-out base branch), the changes will be pushed to a new branch and a pull request created.
  • If there are no changes (i.e. no diff exists with the checked-out base branch), no pull request will be created and the action exits silently.

When I tested this in my fork, it correctly created a PR that looked like #1385

Hmm...I should apply those changes to my main branch and see if the action just no-ops. Will report back here with results!

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ohh hmm, then maybe some of these FCOS actions have been unnecessarily doing a diff? Either way thanks so much for testing this out!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks like my understanding was correct; after applying the generated changes to my main branch, the next time I ran the action there was no PR generated.

https://github.com/miabbott/bootc/actions/runs/15917569924/job/44897979972

Ohh hmm, then maybe some of these FCOS actions have been unnecessarily doing a diff?

In the example you linked, I think you could simplify the "Check if there are new commits" step to just do a git submodule update. If there was a new submodule commit, the PR action would generate the PR otherwise it would no-op.

uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: 'chore: Update generated files'
committer: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
author: 'github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>'
signoff: true
title: 'docs: Update generated'
body: |
This PR was auto-generated by a GitHub Actions workflow.

It contains updates to doc files generated by `cargo xtask update-generated`.
branch: 'actions/update-generated-files'
labels: 'documentation'