alleyinteractive / .github

https://alley.com
1 stars 1 forks source link

Alley Community Health Files

This repository contains the default community health files for the alleyinteractive organization.

Usage

This repository acts as a catch-all for Github organization-wide community files, such as CODE_OF_CONDUCT.md. These community health files will be used unless a repository has their own version.

The repository also contains reusable Github workflows for use on any public repository. These workflows are reused across the organization to perform continuous integration tests with Github Actions.

Reusable Workflows

The following workflows are available to use:

Built Branch

Create a *-built version of a branch for use in submodules.

Inputs

Specify using with keyword.

php
node

Usage

name: Create a -built branch

on:
  push:
    branches:
      - main

jobs:
  built-branch:
    uses: alleyinteractive/.github/.github/workflows/built-branch.yml@main

Built Releases

ℹ️ Note: This action is deprecated in favor of the action-release.

Create built releases of a project based on the WordPress plugin Version header in your main plugin file and then falling back to the version property in either composer.json or package.json. When the version is updated in either file, the action will build the project, push a new tag up with the version, and create a release. Optionally, the release can be drafted or published.

The most common use of this workflow is for WordPress plugins or other packages that require built assets (such as ones from Webpack or Gulp) to be included to work but we don't want to include those assets in version control.

When the plugin's version is incremented on alleyinteractive/create-wordpress-plugin-based plugins via npm run release, the action will push a built version of the plugin to the *-built branch and then create a release with the built assets. If the plugin's version was not incremented, the action will still push the latest changes to the *-built branch but will not create a release. This does mirror the Built Branch workflow but is more flexible and allows for publishing releases.

Inputs

Specify using with keyword.

draft
node

Usage

name: Built Release

on:
  push:
    branches:
      - production

jobs:
  built-asset:
    uses: alleyinteractive/.github/.github/workflows/built-release.yml@main

Built Tag

ℹ️ Note: This action is deprecated in favor of the action-release. Built tags with the format of v*.*.*-built are not compatible with Composer and should be avoided.

Create a *-built version of a tag for use in submodules.

Inputs

Specify using with keyword.

php
node

Usage

name: Create a -built tag

on:
  push:
    tags:
      - 'v*.*.*'
      - '!*-built'

jobs:
  built-tag:
    uses: alleyinteractive/.github/.github/workflows/built-tag.yml@main

Dependabot Auto Merge

Sets Dependabot pull requests to auto merge once they meet the requirements for merging (passes CI, approval, etc. as defined by the protected branch).

Usage

name: dependabot-auto-merge
on:
  pull_request:

permissions:
  pull-requests: write
  contents: write

jobs:
  dependabot:
    uses: alleyinteractive/.github/.github/workflows/dependabot-auto-merge.yml@main

Dependabot Auto Approve

Automatically approves Dependabot pull requests for auto-merging when the default branch for a repository is protected.

Usage

name: dependabot-auto-approve
on:
  pull_request:

permissions:
  pull-requests: write
  contents: write

jobs:
  dependabot:
    uses: alleyinteractive/.github/.github/workflows/dependabot-auto-approve.yml@main

Node Tests

Run automated Node tests against your repository. Assumes that your plugin will have the following commands available to it:

npm run lint
npm run test
npm run build

Inputs

Specify using with keyword.

node
ci
cache
run-audit
run-test
run-lint
run-build
working-directory

Usage

name: Node Tests

on:
  pull_request:

jobs:
  node-tests:
    uses: alleyinteractive/.github/.github/workflows/node-tests.yml@main

PHP Composer Script

Run a set of Composer scripts against your project. Assumes that composer run <command> will run your tests. Supports multiple commands with a multi-line command input.

Note: This workflow does not setup MySQL for testing. Use the PHP Tests with MySQL workflow for that.

Inputs

Specify using with keyword.

command
php
database
working-directory

Usage

name: Composer Tests

on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  composer-lint-phpunit:
    uses: alleyinteractive/.github/.github/workflows/php-composer-command.yml@main
    with:
      command: |
        lint
        phpunit

PHP Tests with MySQL

Run PHPUnit tests against your project. Installs and configures MySQL for WordPress unit testing. Assumes that composer run phpunit will run your unit tests.

Inputs

Specify using with keyword.

action
command
os
php
wordpress
multisite
database
object-cache

dependency-versions

install-core-tests
working-directory

Usage

name: Testing Suite

on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  php-tests:
    uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main

You can also use the PHP tests inside a Github Action Matrix to test against multiple PHP/WordPress versions:

name: Testing Suite

on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  php-tests:
    strategy:
      matrix:
        php: [8.1]
        wordpress: ["latest"]
    uses: alleyinteractive/.github/.github/workflows/php-tests.yml@main
    with:
      php: ${{ matrix.php }}
      wordpress: ${{ matrix.wordpress }}

Deploy to Remote Repository

Uses rsync and git to deploy files/folders from a local GitHub action repository to a remote repository.

Notes:

Inputs

Specify using with keyword.

os
remote_repo
remote_branch
base_directory
destination_directory
exclude_list

Secrets

Specify using secrets keyword.

REMOTE_REPO_SSH_KEY

Usage

Example deploy to VIP:

name: Deploy to VIP repository

on:
  push:
    branches:
      - production
      - preprod
      - develop

jobs:
  sync-to-vip:
    uses: alleyinteractive/.github/.github/workflows/deploy-to-remote-repository.yml@main
    with:
      remote_repo: 'git@github.com:wpcomvip/alley.git'
      exclude_list: '.git, .gitmodules, .revision, .deployment-state, .node_modules, no-vip'
    secrets:
      REMOTE_REPO_SSH_KEY: ${{ secrets.REMOTE_REPO_SSH_KEY }}

Example Deploy to Pantheon multidev sites labeled preprod and develop:

name: Deploy to Pantheon repository

on:
  push:
    branches:
      - preprod
      - develop

jobs:
  sync-to-pantheon:
    uses: alleyinteractive/.github/.github/workflows/deploy-to-remote-repository.yml@main
    with:
      remote_repo: 'ssh://codeserver.dev.SOME-PANTHEON-SITE_ID@codeserver.dev.SOME-PANTHEON-SITE_ID.drush.in:2222/~/repository.git'
      destination_directory: 'wp-content/'
      exclude_list: '.git, pantheon-mu-plugin'
    secrets:
      REMOTE_REPO_SSH_KEY: ${{ secrets.REMOTE_REPO_SSH_KEY }}

PHP Code Quality

Run phpstan tests against your project. Assumes that composer run phpstan will run your tests.

ℹ️ Note: This action is deprecated in favor of the PHP Composer Script workflow.

Inputs

Specify using with keyword.

command
php
dependency-versions
working-directory

Usage

name: Code Quality

on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  code-quality:
    uses: alleyinteractive/.github/.github/workflows/php-code-quality.yml@main

PHP Coding Standards

Run phpcs tests against your project. Assumes that composer run phpcs will run your tests.

ℹ️ Note: This action is deprecated in favor of the PHP Composer Script action.

Inputs

Specify using with keyword.

php
dependency-versions
working-directory

Usage

name: Coding Standards

on:
  push:
    branches:
      - main
  pull_request:
  schedule:
    - cron: '0 0 * * *'

jobs:
  coding-standards:
    uses: alleyinteractive/.github/.github/workflows/php-coding-standards.yml@main