Skip to content

jeffabailey/reusable-workflows

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 

Repository files navigation

Reusable GitHub Actions Workflows

This repository contains reusable GitHub Actions workflows for common deployment and automation tasks.

Available Workflows

hugo-deploy.yml

A comprehensive Hugo deployment workflow that builds and deploys Hugo sites to AWS S3 with CloudFront invalidation.

Features:

  • Hugo build with caching
  • AWS S3 sync with proper ACLs
  • CloudFront cache invalidation
  • Automatic cleanup

Inputs:

  • website_repository (required): The repository containing the Hugo site
  • s3_bucket_name (required): S3 bucket name for deployment
  • cloudfront_distribution_id (required): CloudFront distribution ID for cache invalidation
  • debug (optional): Enable debug mode for verbose output (default: false)

Secrets:

  • aws_access_key_id (required): AWS access key for S3 and CloudFront operations
  • aws_secret_access_key (required): AWS secret key for S3 and CloudFront operations
  • access_token (required): GitHub token for repository checkout

lighthouse-audit.yml

A reusable workflow for running Lighthouse performance audits on websites. Designed to be run on a schedule or manually, separate from deployment workflows.

Features:

  • Lighthouse CI performance auditing
  • Performance budget testing
  • Artifact uploads
  • Temporary public storage for reports

Inputs:

  • site_meta_url (required): Base URL of the site to audit
  • budget_path (optional): Path to budget.json file (default: "./budget.json")
  • upload_artifacts (optional): Upload results as artifacts (default: true)
  • temporary_public_storage (optional): Upload report to temporary public storage (default: true)

Secrets:

  • None required

generate-diagrams.yml

Generates diagrams from Mermaid source files and commits them to the repository.

Features:

  • Mermaid diagram generation
  • Automatic commit of generated images
  • Support for multiple diagram formats

Usage Examples

Hugo Deployment

name: Deploy Website
on:
  push:
    branches: [main]
jobs:
  deploy:
    uses: jeffabailey/reusable-workflows/.github/workflows/hugo-deploy.yml@master
    with:
      website_repository: owner/repo-name
      s3_bucket_name: "my-bucket"
      cloudfront_distribution_id: "E1234567890ABC"
    secrets:
      aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      access_token: ${{ secrets.ACCESS_TOKEN }}

Lighthouse Audit (Scheduled)

name: Lighthouse Audit
on:
  schedule:
    # Run daily at 2 AM UTC
    - cron: '0 2 * * *'
  workflow_dispatch: # Allow manual triggering

jobs:
  lighthouse:
    uses: jeffabailey/reusable-workflows/.github/workflows/lighthouse-audit.yml@master
    with:
      site_meta_url: "https://jeffbailey.us"
      budget_path: "./budget.json" # Optional

Testing and Validation

Local Testing

# Install act for local testing
brew install act

# Test workflows locally
act -n --workflows .github/workflows/hugo-deploy.yml

Secret Validation

Before using these workflows, ensure all required secrets are defined in your repository settings:

  • AWS_ACCESS_KEY_ID: AWS access key
  • AWS_SECRET_ACCESS_KEY: AWS secret key
  • ACCESS_TOKEN: GitHub personal access token

Workflow Dependencies

These workflows use the following actions:

  • aws-actions/configure-aws-credentials@v4
  • actions/checkout@v4
  • actions/cache@v3
  • peaceiris/[email protected]
  • treosh/lighthouse-ci-action@v12
  • rtCamp/action-cleanup@master

Maintenance

Updating Workflows

When updating these workflows:

  1. Test changes locally with act
  2. Update version tags if making breaking changes
  3. Update documentation for any new inputs or secrets
  4. Test with dependent repositories

Version Management

  • Use semantic versioning for workflow tags
  • Maintain backward compatibility when possible
  • Document breaking changes in release notes

Contributing

When contributing to these workflows:

  1. Test changes thoroughly with act
  2. Update documentation for any new features
  3. Ensure all required secrets are documented
  4. Follow GitHub Actions best practices

References

About

Reusable workflows leveraged by all the things.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published