Last active
January 6, 2023 12:43
-
-
Save fabiankaegy/47432c4c8d980ddc553e0f234da49d47 to your computer and use it in GitHub Desktop.
WordPress Project GitHub Actions Setup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Compressed Size | |
on: [pull_request] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/[email protected] | |
with: | |
node-version: 16.x | |
- uses: preactjs/compressed-size-action@v2 | |
with: | |
repo-token: '${{ secrets.GITHUB_TOKEN }}' | |
pattern: '{themes/name/dist/**/*.js,themes/name/dist/**/*.css}' | |
exclude: '{themes/name/dist/blocks/**/index.js,themes/name/dist/**/editor.css,themes/name/dist/**/admin.*,themes/name/dist/**/editor-style-overrides.*,themes/name/dist/**/styleguide.*,themes/name/dist/**/core-block-overrides.js}' | |
compression: 'none' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
push: | |
branches: | |
- develop | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
deploy: | |
name: Develop Environment | |
runs-on: ubuntu-latest | |
environment: | |
name: subdomain.wpengine.com | |
url: https://subdomain.wpengine.com | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Setup Node | |
uses: actions/setup-node@v3 | |
with: | |
node-version-file: '.nvmrc' | |
- name: Get NPM cache directory | |
id: npm-cache-dir | |
run: | | |
echo "::set-output name=dir::$(npm config get cache)" | |
- uses: actions/cache@v3 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install NPM dependencies | |
run: npm ci | |
- name: Build assets | |
run: npm run build --workspaces --if-present | |
- name: Get Composer cache directory | |
id: composer-cache | |
run: | | |
echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-composer- | |
- name: Install Composer dependencies | |
run: composer install --no-dev -o | |
- name: Build mu-plugin | |
run: | | |
cd mu-plugins/name | |
echo $GITHUB_SHA > .commit | |
composer install --no-dev -o | |
cd - | |
- name: Build theme | |
run: | | |
cd themes/name | |
echo $GITHUB_SHA > .commit | |
composer install --no-dev -o | |
- name: Deploy to WP Engine | |
uses: wpengine/github-action-wpe-site-deploy@v3 | |
with: | |
WPE_SSHG_KEY_PRIVATE: ${{ secrets.WPE_SSHG_KEY_PRIVATE }} | |
WPE_ENV: ENVNAME | |
REMOTE_PATH: "wp-content/" | |
FLAGS: -azvr --inplace --delete --exclude-from=deploy-scripts/rsync-excludes.txt | |
CACHE_CLEAR: TRUE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Stylelint | |
on: [pull_request] | |
jobs: | |
stylelint: | |
name: Lint CSS Files | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: stylelint | |
uses: reviewdog/action-stylelint@v1 | |
with: | |
reporter: github-pr-review | |
stylelint_input: 'themes/name/**/*.css' | |
stylelint_config: 'themes/name/stylelint.config.js' | |
fail_on_error: true | |
eslint: | |
name: Lint JS Files | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: eslint | |
uses: reviewdog/action-eslint@v1 | |
with: | |
reporter: github-pr-review | |
eslint_flags: 'themes/name' | |
fail_on_error: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment