feat: add GitHub Actions workflows for code quality and automation (#2)

This commit is contained in:
2025-02-02 00:42:19 +02:00
committed by GitHub
parent af6ecdf6ca
commit 210aa969b3
105 changed files with 8807 additions and 408 deletions

175
README.md
View File

@@ -1,123 +1,88 @@
# ivuorinen/actions - My Reusable GitHub Actions and Workflows
This repository contains reusable GitHub Actions and Workflows that
I have created for my own use. Feel free to use them in your own projects.
## Overview
## Actions
This project contains a collection of workflows and composable actions to streamline CI/CD
processes and ensure code quality. Below is a categorized list of all workflows, grouped by their types.
These actions are composable and can be used together to create more complex workflows.
## Testing Workflows
### `ivuorinen/actions/php-composer`
- [PHP Tests][php-tests]: Runs PHPUnit tests to ensure PHP code correctness.
This action sets up PHP with specified version and installs Composer dependencies.
## Linting and Formatting Workflows
#### Inputs
- [Ansible Lint and Fix][ansible-lint-fix]: Lints and fixes Ansible playbooks and roles.
- [Biome Check][biome-check]: Runs Biome to lint multiple languages and formats.
- [Biome Fix][biome-fix]: Automatically fixes issues detected by Biome.
- [C# Lint Check][csharp-lint-check]: Lints C# code using tools like `dotnet-format`.
- [ESLint Check][eslint-check]: Runs ESLint to check for code style violations.
- [ESLint Fix][eslint-fix]: Automatically fixes code style issues with ESLint.
- [Go Lint Check][go-lint]: Lints Go code using `golangci-lint`.
- [Prettier Check][prettier-check]: Checks code formatting using Prettier.
- [Prettier Fix][prettier-fix]: Automatically fixes code formatting with Prettier.
- [Python Lint and Fix][python-lint-fix]: Lints and fixes Python code using `flake8` and `black`.
- [Terraform Lint and Fix][terraform-lint-fix]: Lints and fixes Terraform
configurations.
- `php`: PHP version to use (default: `8.3`)
- `args`: Additional arguments to pass to Composer
## Build Workflows
#### Example
- [C# Build][csharp-build]: Builds C# projects using the .NET SDK.
- [Docker Build][docker-build]: Builds Docker images using a Dockerfile.
- [Go Build][go-build]: Builds Go projects using the `go build` command.
```yaml
on:
workflow_dispatch:
workflow_call:
pull_request:
paths:
- 'composer.json'
- 'composer.lock'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ivuorinen/actions/php-composer@main
with:
php: '8.3'
args: '--no-dev'
```
## Deployment Workflows
### `ivuorinen/actions/set-git-config`
- [C# Publish][csharp-publish]: Publishes .NET projects to an output directory.
- [Docker Publish to Docker Hub][docker-publish-hub]: Publishes Docker images to Docker Hub.
- [Docker Publish to GitHub Packages][docker-publish-gh]: Publishes Docker images to GitHub's Container Registry.
- [Publish to NPM][npm-publish]: Publishes packages to the NPM registry.
This action sets up Git configuration for the repository.
## Release Workflows
#### Inputs
- [GitHub Release][github-release]: Automates GitHub release creation with custom tags and notes.
- [Release Monthly][release-monthly]: Creates a monthly GitHub release with autogenerated notes.
- `name`: Name to use for Git commits (default: `GitHub Actions`)
- `email`: Email to use for Git commits (default: `github-actions@github.com`)
- `token`: GitHub token to use for Git commits (default: `${{ github.token }}`)
## Utility Workflows
#### Example
```yaml
on:
workflow_dispatch:
workflow_call:
pull_request:
paths:
- '.gitignore'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ivuorinen/actions/set-git-config@main
with:
name: 'GitHub Actions'
email: 'github-actions@github.com'
token: ${{ secrets.GITHUB_TOKEN }}
```
## Workflows
These workflows are complete examples that can be used as-is or as a starting point for your own workflows.
### `ivuorinen/actions/compress-images`
This workflow compresses images in a repository using [calibreapp/image-actions](https://github.com/calibreapp/image-actions).
Defined in the action is a cron job that runs At 23:00 on Sunday and if there are any changes in the repository it creates a pull request with the compressed images.
#### Example
```yaml
# .github/workflows/compress-images.yml
jobs:
compress-images:
uses: ivuorinen/actions/compress-images@main
```
### `ivuorinen/actions/release-monthly`
This workflow creates a monthly release with the current date as the tag name.
#### Example
```yaml
# .github/workflows/release-monthly.yml
jobs:
release-monthly:
uses: ivuorinen/actions/release-monthly@main
```
### `ivuorinen/actions/php-laravel-phpunit`
This workflow sets up PHP with Composer and runs PHPUnit tests for a Laravel project.
#### Example
```yaml
# .github/workflows/php-laravel-phpunit.yml
jobs:
laravel:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: ivuorinen/actions/php-composer@main
with:
php: '8.3'
args: '--no-dev'
```
- [Common File Check][common-file-check]: Checks for the presence of specific files based on a glob pattern.
- [Compress Images][compress-images]: Optimizes and creates a pull request with compressed images.
- [Dotnet Version Detect][dotnet-v-detect]: Detects the required .NET version from `global.json`.
- [Go Version Detect][go-version-detect]: Detects the required Go version from configuration files.
- [Node Setup][node-setup]: Sets up a Node.js environment for workflows.
- [PHP Composer][php-composer]: Installs PHP dependencies using Composer.
- [Pre-Commit][pre-commit]: Runs `pre-commit` hooks to enforce code quality standards.
- [Set Git Config][set-git-config]: Configures Git user information for automated commits.
## License
The code in this repository is licensed under the MIT License. See the [LICENSE.md](LICENSE.md) file for details.
This project is licensed under the MIT License. See the [LICENSE](LICENSE.md) file for details.
[ansible-lint-fix]: ansible-lint-fix/README.md
[biome-check]: biome-check/README.md
[biome-fix]: biome-fix/README.md
[common-file-check]: common-file-check/README.md
[compress-images]: compress-images/README.md
[csharp-build]: csharp-build/README.md
[csharp-lint-check]: csharp-lint-check/README.md
[csharp-publish]: csharp-publish/README.md
[docker-build]: docker-build/README.md
[docker-publish-gh]: docker-publish-gh/README.md
[docker-publish-hub]: docker-publish-hub/README.md
[dotnet-v-detect]: dotnet-version-detect/README.md
[eslint-check]: eslint-check/README.md
[eslint-fix]: eslint-fix/README.md
[github-release]: github-release/README.md
[go-build]: go-build/README.md
[go-lint]: go-lint/README.md
[go-version-detect]: go-version-detect/README.md
[node-setup]: node-setup/README.md
[npm-publish]: npm-publish/README.md
[php-composer]: php-composer/README.md
[php-tests]: php-tests/README.md
[pre-commit]: pre-commit/README.md
[prettier-check]: prettier-check/README.md
[prettier-fix]: prettier-fix/README.md
[python-lint-fix]: python-lint-fix/README.md
[release-monthly]: release-monthly/README.md
[set-git-config]: set-git-config/README.md
[terraform-lint-fix]: terraform-lint-fix/README.md