|
| 1 | +name: Deploy Plugin |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | + pull_request: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + |
| 13 | +jobs: |
| 14 | + test: |
| 15 | + runs-on: ${{ matrix.operating-system }} |
| 16 | + strategy: |
| 17 | + matrix: |
| 18 | + operating-system: [ ubuntu-18.04 ] # OS. ubuntu-18.04 is also available. |
| 19 | + php: [ '5.6', '7.2', '7.4' ] # PHP versions to check. |
| 20 | + wp: [ 'latest', '5.4' ] # WordPress version to check. |
| 21 | + services: |
| 22 | + mysql: |
| 23 | + image: mysql:5.7 |
| 24 | + options: --health-cmd "mysqladmin ping --host 127.0.0.1 --port 3306" --health-interval 20s --health-timeout 10s --health-retries 10 |
| 25 | + ports: |
| 26 | + - 3306/tcp |
| 27 | + env: |
| 28 | + MYSQL_ROOT_PASSWORD: root |
| 29 | + name: WordPress ${{ matrix.wp }} in PHP ${{ matrix.php }} UnitTest |
| 30 | + steps: |
| 31 | + - uses: actions/checkout@master |
| 32 | + |
| 33 | + - name: Setup PHP |
| 34 | + uses: nanasess/setup-php@master |
| 35 | + with: |
| 36 | + php-version: ${{ matrix.php }} |
| 37 | + |
| 38 | + - name: Validate composer.json and composer.lock |
| 39 | + run: composer validate |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: composer install --prefer-dist --no-progress --no-suggest |
| 43 | + |
| 44 | + - name: Start MySQL |
| 45 | + run: sudo systemctl start mysql |
| 46 | + |
| 47 | + - name: Install WordPress |
| 48 | + run: bash bin/install-wp-tests.sh wordpress root root 127.0.0.1:3306 ${{ matrix.wp }} |
| 49 | + |
| 50 | + - name: Check PHP syntax |
| 51 | + run: composer test |
| 52 | + |
| 53 | + assets: |
| 54 | + name: Assets Test |
| 55 | + runs-on: ubuntu-18.04 |
| 56 | + steps: |
| 57 | + - uses: actions/checkout@master |
| 58 | + |
| 59 | + - name: Install Node |
| 60 | + uses: actions/setup-node@v1 |
| 61 | + with: |
| 62 | + node-version: '12' |
| 63 | + |
| 64 | + - name: Install NPM Packages |
| 65 | + run: npm install |
| 66 | + |
| 67 | + - name: Check JS & CSS syntax |
| 68 | + run: npm run lint |
| 69 | + |
| 70 | + release: |
| 71 | + name: Deploy WordPress.org |
| 72 | + needs: [ test, assets ] |
| 73 | + if: contains(github.ref, 'tags/') |
| 74 | + runs-on: ubuntu-18.04 |
| 75 | + steps: |
| 76 | + - name: Checkout code |
| 77 | + uses: actions/checkout@v2 |
| 78 | + |
| 79 | + - name: Setup PHP |
| 80 | + uses: nanasess/setup-php@master |
| 81 | + with: |
| 82 | + php-version: 5.6 |
| 83 | + |
| 84 | + - name: Install Node |
| 85 | + uses: actions/setup-node@v1 |
| 86 | + with: |
| 87 | + node-version: '12' |
| 88 | + |
| 89 | + - name: Build Plugin |
| 90 | + run: bash bin/build.sh ${{ github.ref }} |
| 91 | + |
| 92 | + - name: Deploy to WordPress Directory |
| 93 | + id: deploy |
| 94 | + uses: 10up/action-wordpress-plugin-deploy@stable |
| 95 | + with: |
| 96 | + generate-zip: true |
| 97 | + env: |
| 98 | + SVN_USERNAME: ${{ secrets.WP_ORG_USERNAME_TAROSKY }} |
| 99 | + SVN_PASSWORD: ${{ secrets.WP_ORG_PASSWORD_TAROSKY }} |
| 100 | + |
| 101 | + - name: Create Release |
| 102 | + id: create_release |
| 103 | + |
| 104 | + env: |
| 105 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 106 | + with: |
| 107 | + tag_name: ${{ github.ref }} |
| 108 | + release_name: Release ${{ github.ref }} |
| 109 | + draft: false |
| 110 | + prerelease: false |
| 111 | + |
| 112 | + - name: Upload release asset |
| 113 | + |
| 114 | + env: |
| 115 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + with: |
| 117 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 118 | + asset_path: ${{ github.workspace }}/${{ github.event.repository.name }}.zip |
| 119 | + asset_name: ${{ github.event.repository.name }}.zip |
| 120 | + asset_content_type: application/zip |
0 commit comments