Skip to content

Update from vk-blocks-pro #86

Update from vk-blocks-pro

Update from vk-blocks-pro #86

name: GitHub Release
on:
push:
tags:
- "pre_[0-9]+.[0-9]+.[0-9]+.[0-9]+"
env:
plugin_name: vk-blocks
jobs:
# PHPUnit test ####################################
php_unit:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['7.4', '8.0', '8.1']
wp-versions: ['6.2', '6.3', '6.4']
name: PHP Unit Test on PHP ${{ matrix.php-versions }} / WP ${{ matrix.wp-versions }} Test
services:
mysql:
image: mysql:5.7
ports:
- 3306
env:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
steps:
- uses: actions/checkout@v3
# get the node version from the .node-version file
- name: Read .node-version
run: echo "##[set-output name=NODEVERSION;]$(cat .node-version)"
id: nodenv
# setup node based on the version from the .node-version file, fetched in the previous step
- name: Setup Node.js (.node-version)
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nodenv.outputs.NODEVERSION }}"
- name: Cache multiple paths
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php${{ matrix.php-versions }}-${{ hashFiles('**/composer.lock') }}
- name: Setup PHP ${{ matrix.php-versions }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
- name: install npm scripts
run: npm install
- name: Install Composer Packages
run: composer install
- name: Install WP-CLI
run: |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
chmod +x wp-cli.phar
mv wp-cli.phar /usr/local/bin/wp
- name: Install several WordPress version by wp-env.override.json
run: WP_ENV_PHP_VERSION=${{ matrix.php-versions }} WP_ENV_CORE=WordPress/WordPress#${{ matrix.wp-versions }} npm run wp-env start --update
- name: Check WordPress Version
run: npm run wp-env run cli wp core version
- name: Install Themes
run: bash bin/install-theme.sh
- name: Build
run: npm run build:free
- name: Run PHP Unit Test
run: npm run phpunit:free
# Deploy Test Server and Create GitHub Release ####################################
release:
name: Deploy Test Server and Create GitHub Release
runs-on: ubuntu-latest
needs: [php_unit]
steps:
- name: Checkout code
uses: actions/checkout@v2
# get the node version from the .node-version file
- name: Read .node-version
run: echo "##[set-output name=NODEVERSION;]$(cat .node-version)"
id: nodenv
# setup node based on the version from the .node-version file, fetched in the previous step
- name: Setup Node.js (.node-version)
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nodenv.outputs.NODEVERSION }}"
# リリースするものをビルドする
- name: Install NPM Scripts
run: npm install
- name: Install Composer Packages
run: composer install --optimize-autoloader --prefer-dist --no-dev
- name: Build
run: npm run build:free
- name: Make Distribution
run: bash bin/deploy-test.sh
- name: Deploy test server [ Single ]
uses: burnett01/[email protected]
with:
switches: -avzr
path: /dist/vk-blocks/
remote_path: /home/vs4/www/test/vk-blocks/wp-content/plugins/vk-blocks/
remote_host: ${{ secrets.DEPLOY_HOST_VS4 }}
remote_port: ${{ secrets.DEPLOY_PORT_VS4 }}
remote_user: ${{ secrets.DEPLOY_USER_VS4 }}
remote_key: ${{ secrets.DEPLOY_KEY_VS4 }}
- name: Deploy test server [ Lightning ]
uses: burnett01/[email protected]
with:
switches: -avzr
path: /dist/vk-blocks/
remote_path: /home/vs4/www/test/lightning-g3/wp-content/plugins/vk-blocks/
remote_host: ${{ secrets.DEPLOY_HOST_VS4 }}
remote_port: ${{ secrets.DEPLOY_PORT_VS4 }}
remote_user: ${{ secrets.DEPLOY_USER_VS4 }}
remote_key: ${{ secrets.DEPLOY_KEY_VS4 }}
- name: Create Dist zip file
run : cd dist/ && zip -r ${{ env.plugin_name }}.zip ${{ env.plugin_name }}/
- run : test -e dist/${{ env.plugin_name }}.zip
- name: Create Release
id: create_release
uses: actions/create-release@v1
env :
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/${{ env.plugin_name }}.zip
asset_name: ${{ env.plugin_name }}.zip
asset_content_type: application/zip