diff --git a/README.md b/README.md index 9dedbbd..474c282 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ WayOfDev Logo for light theme WayOfDev Logo for dark theme +

@@ -13,7 +14,7 @@ Software License Commits since latest release Codecov - +Follow on Twitter
@@ -24,28 +25,23 @@ This repository is a collection of [reusable workflows](https://docs.github.com/ These tools encapsulate common and repetitive tasks, allowing for easy integration into multiple projects. This approach not only reduces the need to rewrite code but also ensures standardized operations across all Wayofdev repositories. -Learn more about: - -- [Reusing Workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows) -- [Creating Composite Actions](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action) -
## ๐Ÿ“‹ Table of Contents - [Getting Started](#-getting-started) +- [Composite Actions](#-composite-actions) - [Workflows](#-workflows) - [Auto Label and Release Management](#-auto-label-and-release-management) - [Docker Workflows](#-docker-workflows) - [Code Architecture](#-code-architecture) - [Static Analysis](#-static-analysis) -- [Composite Actions](#-composite-actions) - - [Dependency Management](#-dependency-management) - [License](#-license) - [Security Policy](#-security-policy) - [Contributing](#-want-to-contribute) - [Social Links](#-social-links) - [Author Information](#-author-information) +- [Useful Resources](#-useful-resources)
@@ -55,6 +51,27 @@ To use these workflows and actions, reference them directly from your project's
+## โšก๏ธ Composite Actions + +Composite Actions are a powerful feature of GitHub Actions that allow you to create reusable actions using a combination of other actions, shell commands, or both. + +This enables you to encapsulate a sequence of steps into a single action, making your workflows more modular, easier to maintain, and reducing duplication across your projects. + +Composite Actions can accept inputs and use outputs, making them highly flexible and adaptable to various use cases. + +Check each action's README file for detailed instructions on how to use it. + +| **Action** | **Description** | +|--------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------| +| [`actions/composer/get-cache-directory`](./actions/composer/get-cache-directory/README.md) | Gets the Composer cache directory path and exports it as env variable. | +| [`actions/composer/get-root-version`](./actions/composer/get-root-version/README.md) | determines the Composer root version based on the specified branch and exports it as env variable. | +| [`actions/composer/install`](./actions/composer/install/README.md) | Installs dependencies with Composer based on the specified dependency level. | +| [`actions/phive/install`](./actions/phive/install/README.md) | Install dependencies with [Phive](https://phar.io). | +| [`actions/playwright/install`](./actions/playwright/install/README.md) | Installs [Playwright](https://playwright.dev/) along with its dependencies. | +| [`actions/pnpm/install`](./actions/pnpm/install/README.md) | Installs mono-repository dependencies using [PNPM](https://pnpm.io/). | + +
+ ## โšก๏ธ Workflows Read more about [reusing workflows](https://docs.github.com/en/actions/using-workflows/reusing-workflows). @@ -94,7 +111,29 @@ jobs: ``` +
+.github/labeler.yml + +```yaml +--- +"type: bug": + - head-branch: ['^bug', '^fix', 'bug', 'fix'] + +"type: enhancement": + - head-branch: ['^feature', '^feat', 'feature'] + +"type: documentation": + - changed-files: + - any-glob-to-any-file: ['assets/**/*', '.github/*', './*.md'] + +"type: maintenance": + - changed-files: + - any-glob-to-any-file: ['tests/**/*', '.github/workflows/*'] + +... +``` +

@@ -142,7 +181,7 @@ jobs: #### `build-image.yml:` -This workflow builds a docker image and pushes it to the GitHub Container Registry. +This workflow builds a docker image and pushes it to the Docker Container Registry. Example repositories, using this workflow: @@ -290,247 +329,6 @@ jobs:
-## โšก๏ธ Composite Actions - -Composite Actions are a powerful feature of GitHub Actions that allow you to create reusable actions using a combination of other actions, shell commands, or both. - -This enables you to encapsulate a sequence of steps into a single action, making your workflows more modular, easier to maintain, and reducing duplication across your projects. - -Composite Actions can accept inputs and use outputs, making them highly flexible and adaptable to various use cases. - -### โ†’ Dependency Management - -#### `composer/install:` - -This action installs dependencies with Composer based on the specified dependency level (`lowest`, `locked`, `highest`). It's designed to be flexible, allowing you to specify the working directory for the Composer command. - -Here is an example of how to use this action in your existing workflow: - -
-.github/workflows/integrate.yml - -```yaml ---- - -on: # yamllint disable-line rule:truthy - push: - branches: - - master - pull_request: - -name: ๐Ÿ“ฅ Composer Install - -jobs: - composer-install: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: - - "ubuntu-latest" - php-version: - - "8.2" - dependencies: - - "locked" - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies - uses: wayofdev/gh-actions/actions/composer/install@master - with: - dependencies: ${{ matrix.dependencies }} - working-directory: '.' -``` -
- -
- -#### `composer/get-cache-directory:` - -This action determines the Composer cache directory and exports it as `COMPOSER_CACHE_DIR` environment variable. It allows you to specify the working directory for the Composer command to determine the cache directory. - -Here is an example of how to use this action in your existing workflow: - -
-.github/workflows/integrate.yml - -```yaml ---- - -on: - push: - branches: - - master - pull_request: - -name: ๐Ÿ—‚ Get Composer Cache Directory - -jobs: - get-composer-cache-dir: - runs-on: ubuntu-latest - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: ๐Ÿ” Get Composer Cache Directory - uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master - with: - working-directory: '.' -``` -
- -
- -#### `composer/get-root-version:` - -This action determines the Composer root version based on the specified branch and exports it as `COMPOSER_ROOT_VERSION` environment variable. It's designed to be flexible, allowing you to specify both the branch and the working directory for the Composer command to determine the root version. - -Here is an example of how to use this action in your existing workflow: - -
-.github/workflows/integrate.yml - -```yaml ---- - -on: - push: - branches: - - master - pull_request: - -name: ๐ŸŽฏ Get Composer Root Version - -jobs: - get-composer-root-version: - runs-on: ubuntu-latest - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: ๐ŸŽฏ Get Composer Root Version - uses: wayofdev/gh-actions/actions/composer/get-root-version@master - with: - branch: master - working-directory: '.' -``` -
- -
- -#### `phive/install:` - -This action installs dependencies with [Phive](https://github.com/phar-io/phive), the [Phar Installer](https://phar.io), based on the specified `PHIVE_HOME` directory and a list of trusted `GPG keys`. It's designed to be flexible, allowing you to specify the `PHIVE_HOME directory` and the `GPG keys` to trust for the installation process. - -Here is an example of how to use this action in your existing workflow: - - -
-.github/workflows/integrate.yml - -```yaml ---- - -on: - push: - branches: - - master - pull_request: - -name: ๐Ÿ“ฅ Phive Install - -jobs: - phive-install: - runs-on: ubuntu-latest - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: ๐Ÿ“ฅ Install dependencies with Phive - uses: wayofdev/gh-actions/actions/phive/install@master - with: - phive-home: '.build/phive' - trust-gpg-keys: '0x033E5F8D801A2F8D' -``` -
- -
- -#### `pnpm/install:` - -This action installs mono-repository dependencies using [PNPM](https://pnpm.io/). It's designed to efficiently handle dependencies in a mono-repository setup, enabling corepack support and caching node modules to speed up builds. - -Here is an example of how to use this action in your existing workflow: - -
-.github/workflows/integrate.yml - -```yaml ---- - -on: - pull_request: - types: - - opened - - synchronize - - reopened - paths: - - 'apps/web/**' - - 'packages/**' - - 'package.json' - - 'pnpm*' - - '.github/**' - - 'tsconfig.base.json' - -name: ๐Ÿ” Continuous Integration for Web App - -jobs: - integration: - runs-on: ubuntu-latest - - steps: - - name: ๐Ÿ“ฆ Check out the codebase - uses: actions/checkout@v4 - - - name: โš™๏ธ Setup node - uses: actions/setup-node@v4 - with: - node-version: 20 - registry-url: 'https://registry.npmjs.org/' - - - name: ๐Ÿ“ฅ Install mono-repository dependencies - uses: wayofdev/gh-actions/actions/pnpm-install@master - with: - enable-corepack: true - cache-node-modules: true - -... -``` -
- -For details, see `actions/pnpm-install/action.yaml`. - -**Inputs** - -- `cwd`, optional: Changes node's `process.cwd()` if the project is not located on the root. Default to `process.cwd()`. -- `enable-corepack`, optional: Enable corepack. Default to `false`. -- `cache-prefix`, optional: Add a specific cache-prefix. Default to `default`. -- `cache-node-modules`, optional: Cache node_modules, which might speed up the link step. Default to `false`. - -**Outputs** - -- None - -**Side Effects** - -- This action might create or use caches for `node_modules` based on the `cache-node-modules` and `cache-prefix` settings, potentially affecting subsequent steps in the GitHub Actions workflow. - -
- ## ๐Ÿค License [![Licence](https://img.shields.io/github/license/wayofdev/gh-actions?style=for-the-badge&color=blue)](./LICENSE) @@ -563,7 +361,7 @@ You are more than welcome. Before contributing, kindly check our [contribution g
-## ๐Ÿ™†๐Ÿผโ€โ™‚๏ธ Author Information +## ๐Ÿ‘จโ€๐Ÿ’ป Author Information Created in **2023** by [lotyp](https://github.com/wayofdev) @ [wayofdev](https://github.com/wayofdev) diff --git a/actions/composer/get-cache-directory/README.md b/actions/composer/get-cache-directory/README.md new file mode 100644 index 0000000..395f8c3 --- /dev/null +++ b/actions/composer/get-cache-directory/README.md @@ -0,0 +1,79 @@ +
+
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ +
+ +# Composer / Get Cache Directory Action + +This action determines the Composer cache directory and exports it as `COMPOSER_CACHE_DIR` environment variable. It allows you to specify the working directory for the Composer command to determine the cache directory. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/integrate.yml`, and add the following code to it. + +```yaml +--- + +on: + push: + branches: + - master + pull_request: + +name: ๐Ÿ” Continuous integration + +jobs: + integrate: + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: ๐ŸŽฏ Get Composer Cache Directory + uses: wayofdev/gh-actions/actions/composer/get-cache-directory@master + with: + working-directory: '.' + + # ... + +... +``` + +For details, see [`actions/composer/get-cache-directory/action.yml`](./action.yml) file. + +Real-world examples can be found in the [`wayofdev/laravel-package-tpl`](https://github.com/wayofdev/laravel-package-tpl/blob/master/.github/workflows/integrate.yml) repository. + +
+ +## Structure + +### Inputs + +- `working-directory`, optional: The working directory to use. Defaults to `"."`. + +### Outputs + +none + +### Side Effects + +- The `COMPOSER_CACHE_DIR` environment variable contains the path to the composer cache directory. + +
diff --git a/actions/composer/get-root-version/README.md b/actions/composer/get-root-version/README.md new file mode 100644 index 0000000..ac58122 --- /dev/null +++ b/actions/composer/get-root-version/README.md @@ -0,0 +1,91 @@ +
+
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ +
+ +# Composer / Get Root Version + +This action determines the Composer root version based on the specified branch and exports it as `COMPOSER_ROOT_VERSION` environment variable. It's designed to be flexible, allowing you to specify both the branch and the working directory for the Composer command to determine the root version. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/integrate.yml`, and add the following code to it. + +```yaml +--- + +on: + push: + branches: + - master + pull_request: + +name: ๐Ÿ” Continuous integration + +jobs: + integrate: + runs-on: ubuntu-latest + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: ๐ŸŽฏ Get Composer Root Version + uses: wayofdev/gh-actions/actions/composer/get-root-version@master + with: + branch: master + working-directory: '.' + + # ... + +... +``` + +For details, see [`actions/composer/get-root-version/action.yml`](./action.yml). + +Real-world examples can be found in the [`wayofdev/laravel-package-tpl`](https://github.com/wayofdev/laravel-package-tpl/blob/master/.github/workflows/integrate.yml) repository. + +
+ +## Structure + +### Inputs + +- `branch`, optional: The name of the branch, defaults to `"master"`. +- `working-directory`, optional: The working directory to use, defaults to `"."`. + +### Outputs + +none + +### Side Effects + +- The `COMPOSER_ROOT_VERSION` environment variable contains the root version if it has been defined as `branch-alias` in `composer.json`. + + ```json + { + "extra": { + "branch-alias": { + "dev-master": "11.0-dev" + } + } + } + ``` + +
diff --git a/actions/composer/install/README.md b/actions/composer/install/README.md new file mode 100644 index 0000000..cb5abae --- /dev/null +++ b/actions/composer/install/README.md @@ -0,0 +1,112 @@ +
+ +
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+ +
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ + +
+ +# Composer / Install + +This action installs dependencies with Composer based on the specified dependency level (`lowest`, `locked`, `highest`). It's designed to be flexible, allowing you to specify the working directory for the Composer command. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/integrate.yml`, and add the following code to it. + +```yaml +--- + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + pull_request: + +name: ๐Ÿ” Continuous integration + +jobs: + integrate: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: + - ubuntu-latest + php-version: + - '8.1' + - '8.2' + - '8.3' + dependencies: + - lowest + - locked + - highest + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: ๐Ÿ“ฅ Install "${{ matrix.dependencies }}" dependencies + uses: wayofdev/gh-actions/actions/composer/install@master + with: + dependencies: ${{ matrix.dependencies }} + working-directory: '.' + + # ... + +... +``` + +For details, see [`actions/composer/install/action.yaml`](actions/composer/install/action.yaml). + +Real-world examples can be found in the [`wayofdev/laravel-package-tpl`](https://github.com/wayofdev/laravel-package-tpl/blob/master/.github/workflows/integrate.yml) repository. + +
+ +## Structure + +### Inputs + +- `dependencies`, optional: Which dependencies to install, one of `"lowest"`, `"locked"`, `"highest"` +- `working-directory`, optional: The working directory to use, defaults to `"."`. + +### Outputs + +none + +### Side Effects + +- When `dependencies` is set to `"lowest"`, dependencies are installed in the directory specified by `working-directory` with + + ```bash + $ composer update --ansi --no-interaction --no-progress --prefer-lowest + ```` +- When `dependencies` is set to `"locked"`, dependencies are installed in the directory specified by `working-directory` with + + ```bash + $ composer install --ansi --no-interaction --no-progress + ``` + +- When `dependencies` is set to `"highest"`, dependencies are installed in the directory specified by `working-directory` with + + ```bash + $ composer update --ansi --no-interaction --no-progress + ```` + +
diff --git a/actions/phive/install/README.md b/actions/phive/install/README.md new file mode 100644 index 0000000..0443c63 --- /dev/null +++ b/actions/phive/install/README.md @@ -0,0 +1,99 @@ +
+ +
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+ +
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ + +
+ +# Phive / Install + +This action installs dependencies with [Phive](https://github.com/phar-io/phive), the [Phar Installer](https://phar.io), based on the specified `PHIVE_HOME` directory and a list of trusted `GPG keys`. It's designed to be flexible, allowing you to specify the `PHIVE_HOME` directory and the `GPG keys` to trust for the installation process. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/integrate.yml`, and add the following code to it. + +```yaml +--- + +on: # yamllint disable-line rule:truthy + push: + branches: + - master + pull_request: + +name: ๐Ÿ” Continuous integration + +jobs: + integrate: + runs-on: ubuntu-latest + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: ๐Ÿ“ฅ Install dependencies with Phive + uses: wayofdev/gh-actions/actions/phive/install@master + with: + phive-home: '.build/phive' + trust-gpg-keys: '0x033E5F8D801A2F8D' + + # ... + +... +``` + +For details, see [`actions/phive/install/action.yml`](./action.yml). + +Real-world examples can be found in the [`wayofdev/laravel-package-tpl`](https://github.com/wayofdev/laravel-package-tpl/blob/master/.github/workflows/integrate.yml) repository. + +
+ +## Structure + +### Inputs + +- `dependencies`, optional: Which dependencies to install, one of `"lowest"`, `"locked"`, `"highest"` +- `working-directory`, optional: The working directory to use, defaults to `"."`. + +### Outputs + +none + +### Side Effects + +- When `dependencies` is set to `"lowest"`, dependencies are installed in the directory specified by `working-directory` with + + ```bash + $ composer update --ansi --no-interaction --no-progress --prefer-lowest + ```` + +- ```bash + $ composer install --ansi --no-interaction --no-progress + ``` + +- When `dependencies` is set to `"highest"`, dependencies are installed in the directory specified by `working-directory` with + + ```bash + $ composer update --ansi --no-interaction --no-progress + ```` + +
diff --git a/actions/playwright/install/README.md b/actions/playwright/install/README.md new file mode 100644 index 0000000..7b034f1 --- /dev/null +++ b/actions/playwright/install/README.md @@ -0,0 +1,91 @@ +
+ +
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+ + +
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ + + +
+ +# Playwright / Install + +This GitHub Action installs [Playwright](https://playwright.dev/) along with its dependencies. Playwright is a framework for browser-based automation and testing across multiple browsers. This action supports custom configurations for cache directories and the installation of specific browsers, tailored for efficient testing environments in CI workflows. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/test.yml`, and add the following code to it. + +```yaml +--- + +on: + push: + branches: + - master + pull_request: + +name: ๐Ÿงช E2E testing for web app + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: ๐ŸŽญ Install Playwright + uses: wayofdev/gh-actions/actions/playwright/install@master + with: + playwright-cache-folder: '~/.cache/ms-playwright' + cache-prefix: 'ci-tests' + browsers: 'chromium webkit' + + # ... + +... +``` + +For details, see [`actions/playwright/install/action.yml`](https://chat.openai.com/c/action.yml). + +Real-world examples can be found in the [`wayofdev/next-starter-tpl`](https://github.com/wayofdev/next-starter-tpl/blob/master/.github/workflows/e2e-apps-web.yml) repository. + +
+ +## Structure + +### Inputs + +- `playwright-cache-folder`, optional: Specifies the directory for caching Playwright installations. Defaults to `~/.cache/ms-playwright`. +- `cache-prefix`, optional: A prefix used to invalidate the cache in case of issues. Defaults to `default`. +- `browsers`, optional: Specifies which browsers to install. Defaults to `"chromium webkit"`. + +### Outputs + +none + +### Side Effects + +- Custom configurations are used to set up the Playwright environment, specifically targeting cache management and browser installation. +- The caching mechanism is optimized with a dynamically generated cache key that considers the OS, Playwright version, browser selection, and any specified cache prefix. +- If the cache does not match the current requirements (e.g., due to a version update or change in selected browsers), Playwright will reinstall the necessary components. + +
diff --git a/actions/playwright-install/action.yml b/actions/playwright/install/action.yml similarity index 100% rename from actions/playwright-install/action.yml rename to actions/playwright/install/action.yml diff --git a/actions/pnpm/install/README.md b/actions/pnpm/install/README.md new file mode 100644 index 0000000..0c5b576 --- /dev/null +++ b/actions/pnpm/install/README.md @@ -0,0 +1,96 @@ +
+ +
+WayOfDev Logo for light theme +WayOfDev Logo for dark theme +
+ + +
+
+ +
+Build Status +Software License +Commits since latest release +Codecov + +
+ + + +
+ +# PNPM / Install + +This GitHub Action installs mono-repository dependencies using [PNPM](https://pnpm.io/). It's designed to efficiently handle dependencies in a mono-repository setup, enabling `corepack` support and caching node modules to speed up builds. + +This action is ideal for projects that require optimal dependency management and fast execution of workflows within CI environments. + +
+ +## Example Usage + +Create a new workflow file, for example, `.github/workflows/build.yml`, and add the following code to it. + +```yaml +--- + +on: + push: + branches: + - master + pull_request: + +name: ๐Ÿ” Continuous integration for web app + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: ๐Ÿ“ฆ Check out the codebase + uses: actions/checkout@v4 + + # ... + + - name: โš™๏ธ Setup PNPM mono-repository + uses: wayofdev/gh-actions/actions/pnpm/install@master + with: + cwd: '.' + enable-corepack: true + cache-prefix: 'ci-build' + cache-node-modules: true + + # ... + +... +``` + +For details, see [`actions/pnpm/install/action.yml`](./action.yml). + +Real-world examples can be found in the [`wayofdev/next-starter-tpl`](https://github.com/wayofdev/next-starter-tpl/blob/master/.github/workflows/ci-apps-web.yml) repository. + +
+ +## Structure + +### Inputs + +- `cwd`, optional: Changes Node's process current working directory. Defaults to the root directory (`.`). +- `enable-corepack`, optional: Enables `corepack` to manage package installations. Defaults to `false`. +- `cache-prefix`, optional: Specifies a custom prefix for caching mechanisms. Defaults to `default`. +- `cache-node-modules`, optional: Enables caching of `node_modules` directories. Defaults to `false`. + +### Outputs + +none + +### Side Effects + +- Enabling `corepack` sets up the package manager environment using the system's [corepack](https://nodejs.org/api/corepack.html) feature. +- PNPM is installed or configured according to the presence of `corepack`. +- Caching keys are created and used for faster retrieval of the `node_modules` and pnpm store directories. +- Dependencies are installed with options such as `--no-frozen-lockfile`, `--strict-peer-dependencies`, and `--prefer-offline` to ensure consistency and reproducibility across installations. + +
diff --git a/actions/pnpm-install/action.yml b/actions/pnpm/install/action.yml similarity index 100% rename from actions/pnpm-install/action.yml rename to actions/pnpm/install/action.yml