Skip to content
3warePublic

About

Reusable workflow repository

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

274 Commits

Folders and files

Repository files navigation

3ware reusable workflows

GitHub release issues - workflows CI

Contains GitHub Action reusable workflows and composite actions that can be consumed by other repositories.

Table of contents

Reusable Workflows

Pull Request Checks

Runs the pull request checks used by 3ware repositories: validates the title against the conventional commit specification, waits for required status checks and auto-approves eligible bot pull requests.

Inputs

  • auto-approve-allowed-authors (required). Comma-separated GitHub usernames permitted for auto-approval.
  • auto-approve-path-filters (required). Comma-separated file patterns passed to the auto-approve action. A matching changed file can make a pull request eligible; this is not a substitute for CODEOWNERS.
  • pr-title-scopes (optional). Newline-delimited list of allowed Conventional Commit scopes. Leave empty to allow any scope.

Secrets

GitHub App credentials are required to trigger a check run when an incorrect pull request title is corrected. The App must have contents: write permission.

  • github-app-id (required)
  • github-app-private-key (required)

Permissions

  • checks: read
  • contents: write
  • pull-requests: write

Warning

Avoid defining a workflow-level concurrency group in the calling workflow. The reusable workflow manages concurrency for its jobs.

name: Pull Request CI

on:
  pull_request:
    types: [opened, edited, reopened, synchronize]
    branches: [main]

permissions: {}

jobs:
  pr-check:
    name: PR Checks
    permissions:
      checks: read
      contents: write
      pull-requests: write
    uses: 3ware/workflows/.github/workflows/reusable-pr-checks.yaml@v7.0.0
    with:
      auto-approve-allowed-authors: renovate[bot]
      auto-approve-path-filters: >-
        .github/gh-actions-lock.version,
        .github/workflows/workflow.yaml
      pr-title-scopes: |
        actions
    secrets:
      github-app-id: ${{ secrets.GH_APP_ID }}
      github-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

Trunk Code Quality

Runs trunk code quality, configured via the .trunk/trunk.yaml configuration file, on changes made via pull requests.

Inputs

  • persist-credentials (optional). Defaults to false.
  • owner (optional). Owner the GitHub App token is scoped to. Defaults to the calling repository's owner.
  • additional-repos (optional). Newline delimited repository names, in addition to the calling repository, the token is scoped to. Defaults to workflows.
  • trunk-arguments (optional). Include any CLI arguments supported by trunk check. e.g. --exclude.

Secrets

GitHub App, which creates an organisation token for specific repositories, that allows zizmor to run in online mode.

  • github-app-id (required)
  • github-app-private-key (required)

Permissions

  • contents: read

Warning

Do not define a workflow-level concurrency group in the calling workflow. The reusable workflow already cancels superseded runs on the same pull request; a matching caller group can cause the run to be cancelled as a deadlock.

name: Example Lint Workflow

on:
  pull_request:
    types: [opened, reopened, synchronize]
    branches: [main]

# Disable permissions for all available scopes
permissions: {}

jobs:
  trunk:
    name: Trunk Code Quality
    permissions:
      contents: read
    uses: 3ware/workflows/.github/workflows/reusable-trunk-code-quality.yaml@v6.1.0
    secrets:
      github-app-id: ${{ secrets.GH_APP_ID }}
      github-app-private-key: ${{ secrets.GH_APP_PRIVATE_KEY }}

Composite Actions

Trunk tofu init

Trunk's action uses a composite action defined in setup-ci to prepare a workspace if necessary before any linters are run. Trunk is used to fmt, validate and tflint Infrastructure-as-Code projects. These tools require the IaC directory to be initialised with tofu init. The purpose of trunk-tofu-init is to detect file modification within IaC directories and initialise them prior to running trunk check.

When the IS_TRUNK_UPGRADE or INIT_ALL_MODULES environment variable is true, every directory containing .tf files is initialised instead of only the changed ones.

Inputs

  • tofu-version (required)
  • dir-max-depth (optional, default 3)
  • iac-dir-path (optional, default iac)

Define the following workflow in .trunk/setup-ci/action.yaml:

name: Trunk Code Quality Setup
description: Set up dependencies for Trunk Code Quality

runs:
  using: composite
  steps:
    - name: Initialise OpenTofu Directories
      uses: 3ware/workflows/.github/actions/trunk-tofu-init@v5.0.0
      with:
        tofu-version: 1.13.0

Tip

For ease of configuration follow the recommended IaC project folder structure below

Recommended Folder Structure

iac
├── environments
└── modules
    ├── module1
    └── module2

About

Reusable workflow repository

Topics

Resources

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Used by

Contributors