Skip to content

GitHub Actions workflow to publish specification to GitHub Pages - #148

Merged
joshuagl merged 12 commits into
theupdateframework:masterfrom
joshuagl:joshuagl/gha-ci
Mar 5, 2021
Merged

joshuagl merged 12 commits into
theupdateframework:masterfrom
joshuagl:joshuagl/gha-ci

Conversation

@joshuagl

@joshuagl joshuagl commented Jan 27, 2021 •

Copy link
Copy Markdown
Member

Here's a simple collection of scripts and GitHub Actions workflows to build and publish the bikeshed specification when it is updated.

On pushes to master the workflow will:

  • create a release
  • build that release
  • publish it to both a versioned subdirectory of the gh-pages branch and the latest subdirectory of the gh-pages branch
  • build a simple HTML index to point to all published versions of the bikshed specification (and the draft version)

On pushes to draft the workflow will:

  • build the draft
  • publish it to a draft subdirectory of the gh-pages branch

You can see an example of the automation here in action at https://joshuagl.github.io/specification/

Note: we need GitHub Actions and GitHub Pages enabling for the repository for this to work.

Fixes #145

@joshuagl
joshuagl requested a review from lukpueh January 27, 2021 12:34
@joshuagl

Copy link
Copy Markdown
Member Author

@joshuagl

Copy link
Copy Markdown
Member Author

joshuagl and others added 7 commits February 18, 2021 10:07
* Update to use GHA environment variables
* Remove checks which are handled by GHA configuration -- we will
  configure CI to only run check_release on PRs to master

Signed-off-by: Joshua Lock <[email protected]>
Run our check_release script on each PR to the specification

Signed-off-by: Joshua Lock <[email protected]>
Add some make driven automation to build releases of the specification and
maintain an HTML index of releases. To be driven by a GitHub actions
workflow calling make release with, i.e.
  mkdir build && cd build && make -f ../Makefile release

Adds some helper scripts:
* get_version.py: is a simple Python script which uses a regex to fetch
  the version number from a tuf-spec.md -- the script helps avoid dealing
  with different options between GNU grep (Linux) and BSD grep (macOS
  and other BSDs)
* build_index.py: includes a string which replicates enough of the style
  of the bikeshed formatted specification to build an appropriately
  themed HTML page linking to latest, draft, and versioned releases

Signed-off-by: Joshua Lock <[email protected]>
Add a workflow that will trigger on pushes to master which:
* Builds the HTML version of the spec (using the Makefile) in a build
  directory
* Moves the built HTML file as index.html to a versioned subdirectory
  of build
* Moves the built HTML file as index.html to a 'latest' subdirectory
  of build
* Switches to the 'gh-pages' branch and moves the conents of the build
  directory into the repo root
* Builds an index of published versions as index.html at the root of the
  repo root
* Commits the generated HTML files and pushes them to the gh-pages branch
  on GitHub

Signed-off-by: Joshua Lock <[email protected]>
Add a rule to the Makefile to move draft builds into a draft subdirectory

Signed-off-by: Joshua Lock <[email protected]>
Add a workflow that will trigger on pushes to draft which:
* Builds the HTML version of the spec (using the Makefile) in a build
  subdirectory
* Moves the built HTML file as an index.html to a 'draft' subdirectory
* Switches to the gh-pages branch and moves the contents of the build
  subdirectory into the repo root
* Commits the generated HTML files and pushes them to the gh-pages branch
  on GitHub

Signed-off-by: Joshua Lock <[email protected]>
@joshuagl joshuagl changed the title Add initial GitHub Actions workflow GitHub Actions workflow to publish specification to GitHub Pages Feb 18, 2021
@joshuagl

Copy link
Copy Markdown
Member Author

I've updated this PR to not only convert to GitHub Actions, but also to include workflows to build, release (in the case of master) & publish the specification on pushes to the master and draft branches.

Please take a look @lukpueh, @trishankatdatadog and @mnm678.

@lukpueh lukpueh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Very impressive work, @joshuagl, and as usual, very nicely laid out (re commit separation and messages)!! 🎉

I'd like to take another look at the release and draft workflow files with a fresh set of eyes on Monday, but on a quick glance they seem to do what they should.

Comment thread build_index.py Resolved
Comment thread get_version.py Resolved
Comment thread .github/workflows/pr.yml Resolved
Comment thread .github/workflows/pr.yml Resolved
Our GitHub Actions workflow ensures we are on the correct branch when
running the script during release, and preventing the script from being
used on an arbitrary branch makes testing/debugging harder.

Signed-off-by: Joshua Lock <[email protected]>
Make the name more indicative of the work being performed and ensure we
are only running the job on pushes to the master branch.

Signed-off-by: Joshua Lock <[email protected]>
@joshuagl

Copy link
Copy Markdown
Member Author

Thank you for the detailed review @lukpueh. I've addressed your comments by removing the sanity check code, renaming the PR workflow name and adding a branch specifier to the PR workflow.

lukpueh
lukpueh previously approved these changes Feb 22, 2021

@lukpueh lukpueh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM modulo some minor nits that you may address or not. Many thanks for the excellent PR, @joshuagl!

Comment thread build_index.py Resolved
Comment thread build_index.py Resolved
Comment thread build_index.py Resolved
Comment thread build_index.py Resolved
Comment thread .github/workflows/draft.yml Resolved
on:
workflow_dispatch:
push:
branches: draft

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is also triggered when merging into the branch via GH UI, right?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same comment applies in release.yml.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That's right, a merge pushes changes to the branch and results in a 'push' event.

Comment thread .github/workflows/draft.yml Resolved
Comment thread .github/workflows/release.yml Resolved
Comment thread check_release.py Resolved
* Remove spurious message from check_release script
* Cleanup whitespace in build_index

Signed-off-by: Joshua Lock <[email protected]>
Use the mailing list address for the bot's git user.email. Clarify that
this is a draft specification commit.

Signed-off-by: Joshua Lock <[email protected]>
* Include the specification version in the commit message when adding the
built version to the gh-pages branch.
* Use the mailing list address for the automation's git user.email

Signed-off-by: Joshua Lock <[email protected]>
@joshuagl

Copy link
Copy Markdown
Member Author

LGTM modulo some minor nits that you may address or not. Many thanks for the excellent PR, @joshuagl!

Some good nits, I've addressed each in some follow-on commits. Please review the extra 3 patches and re-approve the PR at your convenience.

@lukpueh lukpueh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

💯

@joshuagl

joshuagl commented Mar 3, 2021

Copy link
Copy Markdown
Member Author

If anyone has the time, I would appreciate a second review on this so we can get it merged and start publishing the newly formatted specification.

@mnm678 mnm678 left a comment

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.

Looks great, thanks for all the work on this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Automated publishing workflow

4 participants