Tests: Use Named Arguments, Part 3 #71
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: WordPress Playground PR Testing | |
| # When to run tests. | |
| on: | |
| pull_request: | |
| types: | |
| - opened | |
| - synchronize | |
| jobs: | |
| build-and-deploy: | |
| # Name. | |
| name: WordPress Playground | |
| # Virtual Environment to use. | |
| # @see: https://github.com/actions/virtual-environments | |
| runs-on: ubuntu-latest | |
| # Define permissions for this action. | |
| permissions: | |
| id-token: write | |
| contents: write | |
| pull-requests: write | |
| # Environment Variables. | |
| # Accessible by using ${{ env.NAME }} | |
| # Use ${{ secrets.NAME }} to include any GitHub Secrets in ${{ env.NAME }} | |
| # The base folder will always be /home/runner/work/github-repo-name/github-repo-name | |
| env: | |
| PLUGIN_SLUG: "convertkit" # The plugin's slug | |
| AWS_ROLE: "arn:aws:iam::048876701201:role/KitWPPluginBuildsRole" | |
| AWS_ROLE_SESSION_NAME: "kit-wordpress" | |
| AWS_BUCKET: "048876701201-kit-wp-plugin-builds" # The Amazon S3 bucket name | |
| AWS_REGION: "us-east-2" # The Amazon S3 region | |
| # Steps to build and provide the Playground URL | |
| steps: | |
| # Checkout (copy) this repository's Plugin to this VM. | |
| - name: Checkout Plugin | |
| uses: actions/checkout@v4 | |
| # Installs Kit WordPress Libraries. | |
| - name: Run Composer | |
| run: composer install --no-dev | |
| # Configure AWS Credentials | |
| - name: Configure AWS credentials | |
| id: credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ env.AWS_ROLE }} | |
| role-session-name: ${{ env.AWS_ROLE_SESSION_NAME }} | |
| aws-region: ${{ env.AWS_REGION }} | |
| # Create ZIP file | |
| - name: Create ZIP File | |
| run: | | |
| zip -r ${{ env.PLUGIN_SLUG }}.zip . -x ".git/*" ".github/*" ".scripts/*" ".wordpress-org/*" "log/*" "tests/*" "*.md" "*.yml" "*.json" "*.neon" "*.lock" "*.xml" "*.dist" "*.example" | |
| # Create base64 encoded version of blueprint JSON for Playground URL. | |
| # See: https://wordpress.github.io/wordpress-playground/blueprints/using-blueprints#base64-encoded-blueprints | |
| - name: Create Blueprint JSON, Base64 Encoded | |
| id: blueprint | |
| run: | | |
| echo "blueprint_json_base64=$(echo -n '{"landingPage": "/wp-admin/index.php","login":true,"steps":[{"step":"installPlugin","pluginData":{"resource":"url","url":"https://${{ env.AWS_BUCKET }}.s3.${{ env.AWS_REGION }}.amazonaws.com/${{ env.PLUGIN_SLUG }}/${{ github.event.pull_request.number }}/${{ env.PLUGIN_SLUG }}.zip"}}]}' | base64 -w 0)" >> $GITHUB_OUTPUT | |
| # Upload to S3 | |
| - name: Upload to S3 | |
| id: upload-s3 | |
| run: | | |
| aws s3 cp ${{ env.PLUGIN_SLUG }}.zip s3://${{ env.AWS_BUCKET }}/${{ env.PLUGIN_SLUG }}/${{ github.event.pull_request.number }}/${{ env.PLUGIN_SLUG }}.zip | |
| # Add comment to PR linking to Playground | |
| - name: Comment on PR | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: `## WordPress Playground | |
| :rocket: Your PR has been built and is ready for testing in WordPress Playground! | |
| [Click here to test your changes in WordPress Playground](https://playground.wordpress.net/#${{ steps.blueprint.outputs.blueprint_json_base64 }})` | |
| }) |