Merge pull request #12336 from google/enhancement/11843-remove-dissmi… #31400
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: Plugin Zip Files | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - main | |
| - 'feature/**' | |
| - 'release/**' | |
| paths: | |
| - '.github/workflows/zips.yml' | |
| - 'bin/release' | |
| - 'assets/**' | |
| - '!assets/**/__tests__/**/*.js' | |
| - '!assets/**/test/*.js' | |
| - '!assets/**/*.test.js' | |
| - 'includes/**' | |
| - 'gtg/**' | |
| - 'google-site-kit.php' | |
| - 'scoper.inc.php' | |
| - 'uninstall.php' | |
| - 'composer.json' | |
| - 'composer.lock' | |
| - 'php-scoper/composer.lock' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'postcss.config.js' | |
| - 'webpack/*.config.js' | |
| - 'webpack.config.js' | |
| - 'feature-flags.json' | |
| tags: ['**'] | |
| pull_request: | |
| branches: | |
| - develop | |
| - main | |
| - 'feature/**' | |
| paths: | |
| - '.github/workflows/zips.yml' | |
| - 'bin/release' | |
| - 'assets/**' | |
| - '!assets/**/__tests__/**/*.js' | |
| - '!assets/**/test/*.js' | |
| - '!assets/**/*.test.js' | |
| - 'includes/**' | |
| - 'google-site-kit.php' | |
| - 'scoper.inc.php' | |
| - 'uninstall.php' | |
| - 'composer.json' | |
| - 'composer.lock' | |
| - 'php-scoper/composer.lock' | |
| - 'package.json' | |
| - 'package-lock.json' | |
| - 'postcss.config.js' | |
| - 'webpack/*.config.js' | |
| - 'webpack.config.js' | |
| - 'feature-flags.json' | |
| types: | |
| - opened | |
| - closed | |
| - reopened | |
| - synchronize | |
| - ready_for_review | |
| workflow_dispatch: | |
| inputs: | |
| release_version: | |
| type: string | |
| description: Release version | |
| required: false | |
| default: '' | |
| concurrency: | |
| group: zips-${{ github.event_name }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GCS_BUCKET: site-kit-github-artifacts | |
| GCS_ROOT_PATH: builds | |
| jobs: | |
| build-zips: | |
| name: Build Zips | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| if: | | |
| false == ( | |
| ( | |
| github.event_name == 'pull_request' && ( | |
| github.event.action == 'closed' || | |
| github.event.pull_request.draft == true || | |
| contains( github.head_ref, 'dependabot/' ) | |
| ) | |
| ) || | |
| github.event.pull_request.head.repo.fork | |
| ) | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '7.4' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Get Composer Cache Directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| - name: Composer Install | |
| run: composer install --no-interaction --no-progress --no-dev | |
| - name: Setup Node.js (.nvmrc) | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version-file: .nvmrc | |
| cache: npm | |
| - name: npm install | |
| run: npm ci --include-workspace-root -w assets | |
| - name: Create destination directory and update file permissions | |
| run: | | |
| mkdir -p "${{ github.ref }}" | |
| sudo chown -R "$(id -u):$(id -g)" . | |
| - name: Build develop version | |
| run: | | |
| npm run dev-zip | |
| mv ./*.zip "${{ github.ref }}/google-site-kit-dev.zip" | |
| - name: Build release version | |
| run: | | |
| npm run release-zip | |
| mv ./*.zip "${{ github.ref }}/google-site-kit.zip" | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: zip-files | |
| path: ${{ github.ref }} | |
| upload-to-cloud-storage: | |
| name: Upload to GCS | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'workflow_dispatch' | |
| needs: build-zips | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: zip-files | |
| path: ${{ github.ref }} | |
| - uses: ./.github/actions/upload-to-gcs | |
| id: upload | |
| with: | |
| credentials-json: ${{ secrets.GCP_CREDENTIALS }} | |
| path: ${{ github.ref }} | |
| destination: ${{ env.GCS_ROOT_PATH }}/${{ github.ref }} | |
| - uses: ./.github/actions/update-pr-comment | |
| if: github.event_name == 'pull_request' | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| section-id: zips | |
| section-content: | | |
| 📦 **Build files for ${{ github.event.pull_request.head.sha }}:** | |
| - Download [development build](${{ steps.upload.outputs.public-url }}/google-site-kit-dev.zip?${{ github.sha }}) | |
| - Download [production build](${{ steps.upload.outputs.public-url }}/google-site-kit.zip?${{ github.sha }}) | |
| remove-zips: | |
| name: Remove Zips | |
| runs-on: ubuntu-latest | |
| if: ( github.event_name == 'pull_request' && github.event.action == 'closed' && contains( github.head_ref, 'dependabot/' ) == false ) && github.event.pull_request.head.repo.fork == false | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - uses: ./.github/actions/remove-gcs-path | |
| with: | |
| credentials-json: ${{ secrets.GCP_CREDENTIALS }} | |
| path: ${{ env.GCS_ROOT_PATH }}/refs/pull/${{ github.event.pull_request.number }} | |
| - uses: ./.github/actions/update-pr-comment | |
| with: | |
| issue-number: ${{ github.event.pull_request.number }} | |
| section-id: zips | |
| section-content: | | |
| 📦 **Build files for ${{ github.event.pull_request.head.sha }}:** | |
| - Build files have been deleted. | |
| dryrun-publish-to-wporg: | |
| name: '[DRY RUN] Publish to WordPress.org' | |
| runs-on: ubuntu-latest | |
| # environment: do not define to omit SVN credentials + deployment protection rules for this dry-run. | |
| if: github.event_name == 'workflow_dispatch' && ( github.ref_type == 'tag' || inputs.release_version != '' ) | |
| needs: build-zips | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Install SVN ( Subversion ) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install subversion | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: zip-files | |
| path: /tmp | |
| - name: Extract | |
| run: | | |
| unzip /tmp/google-site-kit.zip | |
| - uses: 10up/action-wordpress-plugin-deploy@2.2.2 | |
| with: | |
| dry-run: true | |
| env: | |
| BUILD_DIR: ./google-site-kit | |
| SLUG: google-site-kit | |
| SVN_PASSWORD: no-op-password | |
| SVN_USERNAME: no-op-username | |
| VERSION: ${{ inputs.release_version }} | |
| publish-to-wporg: | |
| name: Publish to WordPress.org | |
| runs-on: ubuntu-latest | |
| environment: wordpress-plugin-svn | |
| if: github.event_name == 'workflow_dispatch' && ( github.ref_type == 'tag' || inputs.release_version != '' ) | |
| needs: build-zips | |
| timeout-minutes: 20 | |
| steps: | |
| - name: Install SVN ( Subversion ) | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install subversion | |
| - uses: actions/download-artifact@v7 | |
| with: | |
| name: zip-files | |
| path: /tmp | |
| - name: Extract | |
| run: | | |
| unzip /tmp/google-site-kit.zip | |
| - uses: 10up/action-wordpress-plugin-deploy@2.2.2 | |
| env: | |
| BUILD_DIR: ./google-site-kit | |
| SLUG: google-site-kit | |
| SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} | |
| SVN_USERNAME: ${{ secrets.SVN_USERNAME }} | |
| VERSION: ${{ inputs.release_version }} |