| .github/
| | .workflows/ # the directory which holds all workflow files
| docs/
| | workflow-docs/ # each workflow must have its own documentation in here
| examples/ # each workflow must contain a fully complete example of usage here
Welcome to the getting started guide for using Init4's shared Github Actions workflows. The goal of this repository is to give developers standard and secure building blocks to bootstrap CI in their repositories quickly and with minimal action configuration.
In Github Actions everything is built around workflows. When you configure a workflow.yml
file in your repo you normally need to have many steps and need to know all the different CI actions you want. Annoyingly, this has to be done every time you set up a repo, and commonly results in lots of copy and pasting code all around. While manageable, it creates a lot of what I call "complexity creep" where CI steps get added and shared around without much intent. This creates CI bloat and can be a big time waster.
To fix this issue here at Init4 we can leverage the shared workflows contained in this repository, and creating your new repository with a robust CI workflow with as few as 10 lines of yaml. Each of the supplied workflows are designed to be as lightweight as possible without sacrificing baseline security. Workflows also have optional parameters that may be provided to give individual repositories further ability to configure the steps they need with simple booleans. Each workflow must also contain a docs/<workflow_name>.md
file with all optional parameters documented.
-
Create your new repository and add any code you have to get it structured how you'd like.
-
Create the directories
.github/workflows
at the root of your repository -
Add a CODEOWNERS file at
.github/CODEOWNERS
-
Create your CI workflow using one of our
*-base.yml
workflows to startsolidity-base.yml
example (seeexamples
folder for others)name: CI # executes automatically on pull requests and pushes to main on: pull_request: push: branches: - main workflow_dispatch: # the only configuration needed for the solidity-base workflow jobs: solidity-base: uses: init4tech/actions/.github/workflows/solidity-base.yml@main
-
You now have a fully initialized repository, go code!
-
Find the workflow to modify in the directory
.github/workflows/
-
Add a new
input:
parameter of typeboolean
to the workflow with the default set tofalse
-
Add a new step and include an
if:
block to check your new input parameter and optionally install your dependency- for an example, see the "Optional Foundry install Step" below:
steps: - name: Checkout repository uses: actions/checkout@v3 - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable - uses: Swatinem/rust-cache@v2 - name: Optional Foundry Install if: ${{ github.event.inputs.install-foundry == 'true' }} uses: foundry-rs/foundry-toolchain@v1 with: version: nightly - name: Run tests run: | cargo test --all-features --workspace