Refactor Github Action per b/485167538 (#14449) #11951
Workflow file for this run
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: Build plugin | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - release/* | |
| pull_request: | |
| jobs: | |
| build: | |
| name: Package ZIP files | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Read .nvmrc | |
| run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)" | |
| id: nvm | |
| - name: Setup Node | |
| uses: actions/setup-node@v2.1.4 | |
| with: | |
| node-version: '${{ steps.nvm.outputs.NVMRC }}' | |
| - name: Cache node modules | |
| uses: pat-s/always-upload-cache@v2.1.3 | |
| with: | |
| # npm cache files are stored in `~/.npm` on Linux/macOS | |
| path: ~/.npm | |
| key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-build-${{ env.cache-name }}- | |
| ${{ runner.os }}-build- | |
| ${{ runner.os }}- | |
| env: | |
| cache-name: cache-node-modules | |
| - name: Setup PHP | |
| uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '7.4' | |
| coverage: none | |
| tools: composer:v1 | |
| - name: Get Composer cache directory | |
| id: composer-cache | |
| run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
| - name: Setup Composer cache | |
| uses: pat-s/always-upload-cache@v2.1.3 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-composer- | |
| ${{ runner.os }}- | |
| - name: Install dependencies | |
| run: | | |
| npm ci | |
| composer install --prefer-dist --no-suggest --no-progress --no-interaction | |
| env: | |
| CI: true | |
| PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true | |
| - name: Build plugin | |
| run: | | |
| npm run build:js | |
| npm run workflow:version -- --nightly | |
| mkdir -p build/web-stories-composer build/web-stories-regular build/web-stories-dev | |
| - name: Bundle composer version | |
| run: | | |
| npm run workflow:build-plugin -- --composer | |
| mv build/web-stories build/web-stories-composer/ | |
| - name: Bundle regular version | |
| run: | | |
| npm run workflow:build-plugin | |
| mv build/web-stories build/web-stories-regular/ | |
| - name: Bundle development version | |
| run: | | |
| rm -rf assets/css/* assets/js/* | |
| NODE_ENV=development npx webpack --config webpack.config.cjs | |
| npm run workflow:build-plugin | |
| mv build/web-stories build/web-stories-dev/ | |
| - name: Upload composer bundle | |
| uses: actions/upload-artifact@v2 | |
| with: | |
| name: web-stories-composer | |
| path: build/web-stories-composer | |
| - name: Upload regular bundle | |
| uses: actions/upload-artifact@v2 | |
| with: | |
| name: web-stories | |
| path: build/web-stories-regular | |
| - name: Upload development bundle | |
| uses: actions/upload-artifact@v2 | |
| with: | |
| name: web-stories-dev | |
| path: build/web-stories-dev | |
| upload-to-wiki: | |
| name: Upload ZIP files to storage | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: ${{ github.repository }}.wiki | |
| ref: master | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v2 | |
| with: | |
| path: ${{ github.ref }} | |
| - name: ZIP artifacts | |
| run: | | |
| rm -rf web-stories.zip web-stories-composer.zip web-stories-composer web-stories-dev.zip | |
| (cd web-stories && zip -mrT web-stories.zip web-stories && mv web-stories.zip ../ ) | |
| (cd web-stories-dev && zip -mrT web-stories-dev.zip web-stories && mv web-stories-dev.zip ../ ) | |
| working-directory: ${{ github.ref }} | |
| - name: Commit updates | |
| run: | | |
| git add . | |
| git status | |
| git commit -m "Build and publish ${GITHUB_REF}" | |
| git pull --no-edit --quiet | |
| git push origin master | |
| env: | |
| GIT_AUTHOR_EMAIL: ${{ github.actor }}@users.noreply.github.com | |
| GIT_AUTHOR_NAME: ${{ github.actor }} | |
| GIT_COMMITTER_EMAIL: ${{ github.actor }}@users.noreply.github.com | |
| GIT_COMMITTER_NAME: ${{ github.actor }} | |
| deploy-to-staging: | |
| name: Deploy to staging environment | |
| needs: build | |
| runs-on: ubuntu-latest | |
| if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v2 | |
| - name: Download full bundle | |
| uses: actions/download-artifact@v2 | |
| with: | |
| name: web-stories | |
| path: build | |
| - name: Setup SSH Keys and known_hosts | |
| uses: webfactory/ssh-agent@v0.4.1 | |
| with: | |
| ssh-private-key: ${{ secrets.PANTHEON_DEPLOY_KEY }} | |
| - name: Run deployment | |
| run: bash bin/deploy-to-test-environment.sh |