Skip to content
tonyputiPublic

About

Reusable GitHub Actions workflows and actions

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

55 Commits

Folders and files

Repository files navigation

Reusable GitHub Actions Workflows

Centralized reusable workflows and composite actions for tonyputi personal account, shared across tonyputi/* repositories.

Quick Reference

Workflows

Workflow Description Status
generate-semantic-release Automated semantic versioning and releases Active
deploy-laravel-app Laravel deploy via SCP + SSH Active
test-php-app PHP test runner Active
lint Lint checks (yaml, shell, dockerfile) Active
scan-iac Security scanning for IaC (Terraform/Ansible/Docker) Active
auto-merge Opt Dependabot PRs into native auto-merge Available
update-dependabot-branches Update already opted-in Dependabot PR branches Enabled; live verification pending

Actions

Action Description
setup/sops Install SOPS and configure age key for secrets decryption
setup/ansible Install Ansible and Galaxy collections
setup/composer PHP Composer setup with caching
setup/node Node.js setup with caching
setup/ssh-key Configure SSH key and known hosts
lint/yaml Run yamllint on YAML files
lint/shell Run ShellCheck on shell scripts
lint/dockerfile Run Hadolint on Dockerfiles

Usage

Reference workflows and actions at @main or at a pinned version tag:

# Workflows
uses: tonyputi/.github/.github/workflows/generate-semantic-release.yml@main

# Actions
uses: tonyputi/.github/actions/setup/sops@main

Workflow Documentation

Generate Semantic Release

Automated semantic versioning using semantic-release with GitHub App authentication.

Features:

  • Automatic version bumping based on conventional commits
  • Auto-discovers plugins from release.config.js or release.config.cjs
  • Changelog and GitHub release creation
Example usage
jobs:
  release:
    uses: tonyputi/.github/.github/workflows/generate-semantic-release.yml@main
    with:
      github_app_id: ${{ vars.GH_APP_ID }}
    secrets:
      github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}

Inputs:

Input Required Description
github_app_id Yes GitHub App ID

Secrets:

Secret Required Description
github_app_private_key Yes GitHub App private key (PEM)

Outputs:

Output Description
release_published true if a new release was created
release_version The new version number (e.g., 1.2.3)

Dependabot Auto-Merge

Opts Dependabot PRs into native squash auto-merge after a successful PR CI run. GitHub still requires the configured checks and human CODEOWNER approval; if both are already satisfied, the merge can happen immediately. No approval is submitted.

Before adding the caller, enable repository auto-merge and squash merging, and require human CODEOWNER approval and reliable checks on the default branch, with no App bypass. Ensure CODEOWNERS covers the repository. The workflow does not create or validate these repository settings; Terraform manages them separately. For this repository, require both Lint Shell Scripts and Lint YAML as native checks.

Add this caller on the consumer's default branch. Replace CI with its actual PR workflow name and <reviewed-commit-sha> with the shared workflow's final reviewed merge commit SHA:

name: Dependabot Auto-Merge

on:
  workflow_run:
    workflows: ['CI']
    types: [completed]

permissions:
  contents: read
  pull-requests: read

jobs:
  auto-merge:
    uses: tonyputi/.github/.github/workflows/auto-merge.yml@<reviewed-commit-sha>
    with:
      github_app_id: ${{ vars.GH_APP_ID }}
    secrets:
      github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}

github_app_id (string input) and github_app_private_key (secret) are required, using the same interface as the release workflow. Configure them in the caller: secrets stored in tonyputi/.github do not propagate. The App must be installed on the caller with Contents and Pull requests write permissions; its temporary token is restricted to that repository and those permissions. Do not give it a ruleset bypass. An App token, rather than GITHUB_TOKEN, lets merges trigger the normal push/release workflows.

The workflow_run caller allows access to Actions secrets without running PR code. The reusable reads only PR metadata: it ignores failed/non-PR/fork runs, human PRs, drafts, closed PRs, other base branches and heads changed since the CI run. It never checks out code, downloads artifacts, restores caches or executes PR content. All eligible Dependabot update types are included; titles are not rewritten. GitHub remains responsible for the current required checks and reviews.

There is no activation flag: adding the caller opts in. To opt out, remove it and cancel its active runs. Disable auto-merge separately on already queued PRs.


Dependabot Branch Updates

update-dependabot-branches.yml complements auto-merge.yml. It merges the current upstream default branch into eligible PR branches using GitHub's non-destructive update-branch API and an expected_head_sha guard. It never opts a PR into auto-merge, submits approval, merges a PR, force-pushes or changes repository protections.

This repository enables branch updates through .github/workflows/dependabot-branch-updates.yml. Its local workflow reference resolves to the same commit as the caller, without a moving branch reference. It runs on default-branch pushes, every six hours, and manual dispatch.

Live verification is pending: there are currently no open Dependabot PRs to use. The next naturally occurring eligible PR will provide evidence of automatic branch updates, fresh CI and enforced human review. Other repositories, including tonyputi/resume, remain separate adoptions after that evidence is recorded.

The caller must have repository-owned Dependabot configuration, native auto-merge, strict required checks, human CODEOWNER approval, stale-approval dismissal and no App bypass. Keep settings in Terraform. Keep the existing CI-completion auto-merge caller; this workflow does not replace it. Required check names must remain stable.

A single repository-scoped App token reads metadata and updates PR branches. The installed App needs Contents and Pull requests write, plus Checks and Commit statuses read. Ensure any newly added App permissions are accepted for the caller's installation. The temporary token requests only these permissions and only the caller repository. Missing credentials or permissions fail the run; there is no PAT or GITHUB_TOKEN fallback.

Other repositories can adopt this small caller on their default branch after live verification here. Pin the shared workflow to its reviewed merged commit:

name: Update Dependabot Branches

on:
  push:
    branches: ['**']
  schedule:
    - cron: '17 */6 * * *'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  update-branches:
    uses: tonyputi/.github/.github/workflows/update-dependabot-branches.yml@<reviewed-commit-sha>
    with:
      github_app_id: ${{ vars.GH_APP_ID }}
    secrets:
      github_app_private_key: ${{ secrets.GH_APP_PRIVATE_KEY }}

The reusable accepts only default-branch pushes (not tags, deletions or PR-head pushes), scheduled recovery, and manual dispatch. The broad branch trigger follows default-branch renames without hard-coding main; the reusable checks the actual repository default. Recovery scans run every six hours, subject to GitHub schedule delays/disablement, and each run is limited to ten minutes with no API error retries. Initially unknown mergeability gets at most three metadata rereads, each after a two-second wait, before deferring. Manual dispatch provides recovery if a push or scheduled event is missed.

Each run fetches current repository/PR metadata and processes PRs serially. A fixed repository concurrency group prevents overlapping updater runs; active runs are not cancelled. Pending events can be coalesced because every run scans all open PRs rather than trusting an event's old head/base SHA. Eligibility requires the verified Dependabot login and numeric ID, an open non-draft PR, both repositories matching the caller, the current default base branch, and native auto-merge already enabled. Forks, human PRs and PRs not opted in are untouched.

Branches already containing the current base need no update. Conflicts fail the run; failed or pending checks and unknown mergeability are reported without an update. The workflow checks the current head, actual base-branch ref, default branch and eligibility again before writing; cached PR base.sha metadata is not used as the current branch tip. A changed head/base is deferred; a late head race is rejected by GitHub's expected-head guard. GitHub does not offer an expected-base guard for this endpoint: a default-branch advance immediately after the final read can still leave a PR behind. The next push/recovery run handles it; strict native rules block an outdated merge in the meantime. API errors fail visibly with no immediate retry.

An accepted update uses an App token so pull_request synchronization starts fresh consumer CI. GitHub must enforce checks on the new head; old green checks do not authorize a merge. Human approvals can be dismissed by the update, and the workflow never replaces them. Fully unattended merging is not promised: review the new head and supply a new human approval when required. If fresh CI fails or does not start, inspect the caller's PR triggers, App permissions and Actions runs; do not bypass the checks or repeatedly update an already current branch. Resolve conflicts or failed checks manually, then rerun via dispatch. To opt out, remove the caller and cancel its runs; disabling existing native auto-merge remains a separate action.

Privileged execution is metadata-only: no checkout, PR code, artifacts or caches. The workflow downloads scripts/update-dependabot-branches.js from an immutable commit in tonyputi/.github, never from the caller or a PR head. Download failures stop execution before the App token is created. Actions and the script source are pinned, API metadata is never interpolated into shell source, and errors do not print API payloads. Live verification must record PR/run URLs for base advancement, new head/CI, dismissed approval blocking, repeated events and native auto-merge after valid checks and human review.


Scan IaC

Security scanning for Infrastructure-as-Code using Checkov.

Features:

  • Supports Terraform, Ansible, Dockerfile, Kubernetes, GitHub Actions
  • Configurable skip checks and paths
  • Soft fail mode for non-blocking scans
Example usage
jobs:
  security:
    uses: tonyputi/.github/.github/workflows/scan-iac.yml@main
    with:
      framework: ansible
      soft_fail: true
      skip_path: 'collections/,.github/'

Inputs:

Input Default Description
framework all Framework to scan (terraform, ansible, dockerfile, kubernetes, github_actions, all)
soft_fail false Treat failures as warnings
skip_checks - Comma-separated check IDs to skip
skip_path - Comma-separated paths to skip

Actions Documentation

setup/sops

Install SOPS and configure age key for secrets decryption.

Example usage
- name: Setup SOPS
  uses: tonyputi/.github/actions/setup/sops@main
  with:
    age-key: ${{ secrets.SOPS_AGE_KEY }}

Inputs:

Input Required Default Description
version No 3.8.1 SOPS version to install
age-key Yes - Age private key for decryption

setup/ansible

Install Ansible and Galaxy collections.

Example usage
- name: Setup Ansible
  uses: tonyputi/.github/actions/setup/ansible@main

setup/ssh-key

Configure SSH key and known hosts for remote server access.

Example usage
- name: Setup SSH Key
  uses: tonyputi/.github/actions/setup/ssh-key@main
  with:
    ssh_key: ${{ secrets.SERVER_SSH_KEY }}
    hosts: 'example.com'

Inputs:

Input Required Default Description
ssh_key Yes - SSH private key
key_name No id_ed25519 Name for the key file
hosts No - Comma-separated hosts for ssh-keyscan
known_hosts No - Known hosts content (alternative to hosts)

lint/yaml

Run yamllint on YAML files. Auto-detects config files (.yamllint.yml, .yamllint).

Example usage
- name: Lint YAML
  uses: tonyputi/.github/actions/lint/yaml@main

lint/shell

Run ShellCheck on shell scripts.

Example usage
- name: Lint shell scripts
  uses: tonyputi/.github/actions/lint/shell@main
  with:
    path: 'scripts'

lint/dockerfile

Run Hadolint on Dockerfiles.

Example usage
- name: Lint Dockerfiles
  uses: tonyputi/.github/actions/lint/dockerfile@main

Contributing

  1. Place workflows in .github/workflows/ with action-first naming (deploy-*, scan-*, generate-*)
  2. Use workflow_call trigger
  3. Document all inputs, secrets, and outputs
  4. Update this README
  5. Use conventional commits:
    • feat: → minor version bump
    • fix: → patch version bump
    • feat!: → major version bump

About

Reusable GitHub Actions workflows and actions

Topics

Resources

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages