|
| 1 | +# Runs WordPress Plugin Check on modified plugins to ensure compliance with |
| 2 | +# WordPress.org guidelines and coding standards. |
| 3 | +# |
| 4 | +# https://wordpress.org/plugins/plugin-check/ |
| 5 | + |
| 6 | +name: Plugin Check |
| 7 | + |
| 8 | +on: |
| 9 | + push: |
| 10 | + branches: |
| 11 | + - main |
| 12 | + paths: |
| 13 | + - 'plugins/**' |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + paths: |
| 18 | + - 'plugins/**' |
| 19 | + |
| 20 | +jobs: |
| 21 | + detect-plugins: |
| 22 | + runs-on: ubuntu-latest |
| 23 | + name: Detect modified plugins |
| 24 | + outputs: |
| 25 | + plugins: ${{ steps.detect.outputs.plugins }} |
| 26 | + has-plugins: ${{ steps.detect.outputs.has-plugins }} |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Get changed plugin directories |
| 32 | + id: plugin |
| 33 | + run: | |
| 34 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 35 | + bash .github/scripts/get_plugin_slug.sh main |
| 36 | + else |
| 37 | + bash .github/scripts/get_plugin_slug.sh \ |
| 38 | + ${{ github.event.pull_request.base.sha }} \ |
| 39 | + ${{ github.event.pull_request.head.sha }} |
| 40 | + fi |
| 41 | +
|
| 42 | + - name: Set output |
| 43 | + id: detect |
| 44 | + run: | |
| 45 | + # get_plugin_slug.sh outputs: slug, plugins (JSON array), has-plugins |
| 46 | + if [ -z "${{ steps.plugin.outputs.slug }}" ]; then |
| 47 | + echo "plugins=[]" >> $GITHUB_OUTPUT |
| 48 | + echo "has-plugins=false" >> $GITHUB_OUTPUT |
| 49 | + exit 0 |
| 50 | + fi |
| 51 | + echo "plugins=${{ steps.plugin.outputs.plugins }}" >> $GITHUB_OUTPUT |
| 52 | + echo "has-plugins=${{ steps.plugin.outputs.has-plugins }}" >> $GITHUB_OUTPUT |
| 53 | +
|
| 54 | + plugin-check: |
| 55 | + needs: detect-plugins |
| 56 | + if: needs.detect-plugins.outputs.has-plugins == 'true' |
| 57 | + runs-on: ubuntu-latest |
| 58 | + strategy: |
| 59 | + matrix: |
| 60 | + plugin: ${{ fromJson(needs.detect-plugins.outputs.plugins) }} |
| 61 | + fail-fast: false |
| 62 | + name: ${{ matrix.plugin }} |
| 63 | + steps: |
| 64 | + - name: Checkout |
| 65 | + uses: actions/checkout@v4 |
| 66 | + |
| 67 | + - name: Run Plugin Check |
| 68 | + uses: wordpress/plugin-check-action@v1 |
| 69 | + with: |
| 70 | + build-dir: plugins/${{ matrix.plugin }} |
| 71 | + exclude-directories: | |
| 72 | + .git |
| 73 | + vendor |
| 74 | + node_modules |
| 75 | + tests |
| 76 | + ignore-warnings: true |
| 77 | + include-experimental: false |
0 commit comments