🔥 Remove deprecated composer arguments #673
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: PR Playground Demo | |
| on: | |
| pull_request: | |
| types: [opened, synchronize, reopened] | |
| paths: | |
| - "src/**" | |
| - "assets/**" | |
| - "modules/**" | |
| - "package.json" | |
| - "composer.json" | |
| push: | |
| paths: | |
| - "src/**" | |
| - "assets/**" | |
| - "modules/**" | |
| - "package.json" | |
| - "composer.json" | |
| # Cancels all previous workflow runs for pull requests that have not completed. | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }} | |
| cancel-in-progress: true | |
| # Disable permissions for all available scopes by default. | |
| permissions: {} | |
| jobs: | |
| prepare_version: | |
| runs-on: ubuntu-latest | |
| # Only run for the main repository, not forks | |
| if: github.repository == 'woocommerce/woocommerce-paypal-payments' && github.event_name == 'pull_request' | |
| outputs: | |
| artifact_name: ${{ steps.version.outputs.artifact_name }} | |
| plugin_version: ${{ steps.version.outputs.plugin_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set plugin version and artifact name | |
| id: version | |
| run: | | |
| BASE_VERSION=$(sed -nE '/Version:/s/.* ([0-9.]+).*/\1/p' woocommerce-paypal-payments.php) | |
| VERSUFFIX="${GITHUB_RUN_ID}-g$(git rev-parse --short HEAD)" | |
| PR_VERSION="${BASE_VERSION}-pr${{ github.event.pull_request.number }}-${VERSUFFIX}" | |
| ARTIFACT_NAME="woocommerce-paypal-payments-${PR_VERSION}" | |
| echo "plugin_version=$PR_VERSION" >> $GITHUB_OUTPUT | |
| echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
| build_plugin: | |
| needs: prepare_version | |
| uses: inpsyde/reusable-workflows/.github/workflows/build-plugin-archive.yml@a9af34f34e95cbe18703198c7e972e97ebcd7473 | |
| with: | |
| PHP_VERSION: 7.4 | |
| NODE_VERSION: 22 | |
| PLUGIN_MAIN_FILE: ./woocommerce-paypal-payments.php | |
| PLUGIN_VERSION: ${{ needs.prepare_version.outputs.plugin_version }} | |
| PLUGIN_FOLDER_NAME: woocommerce-paypal-payments | |
| ARCHIVE_NAME: ${{ needs.prepare_version.outputs.artifact_name }} | |
| COMPILE_ASSETS_ARGS: "-vv --env=root" | |
| create_archive: | |
| runs-on: ubuntu-latest | |
| needs: [prepare_version, build_plugin] | |
| outputs: | |
| artifact_name: ${{ needs.prepare_version.outputs.artifact_name }} | |
| plugin_version: ${{ needs.prepare_version.outputs.plugin_version }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Save PR details | |
| run: | | |
| mkdir -p ./pr | |
| echo "${{ github.event.pull_request.number }}" > ./pr/NR | |
| echo "${{ needs.prepare_version.outputs.plugin_version }}" > ./pr/VERSION | |
| echo "${{ needs.prepare_version.outputs.artifact_name }}" > ./pr/ARTIFACT | |
| - name: Upload PR number | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: pr-details | |
| path: pr/ | |
| playground_demo: | |
| name: Comment on PR with Playground details | |
| runs-on: ubuntu-latest | |
| needs: create_archive | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| # Only run for pull requests in the main repository | |
| if: github.repository == 'woocommerce/woocommerce-paypal-payments' && github.event_name == 'pull_request' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download PR details artifact | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| run_id: context.runId, | |
| }); | |
| const matchArtifact = artifacts.data.artifacts.filter((artifact) => { | |
| return artifact.name === 'pr-details' | |
| })[0]; | |
| if (!matchArtifact) { | |
| core.setFailed('No pr-details artifact found!'); | |
| return; | |
| } | |
| const download = await github.rest.actions.downloadArtifact({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| artifact_id: matchArtifact.id, | |
| archive_format: 'zip', | |
| }); | |
| const fs = require('fs'); | |
| fs.writeFileSync('${{github.workspace}}/pr-details.zip', Buffer.from(download.data)); | |
| - name: Unzip PR details | |
| run: unzip pr-details.zip | |
| - name: Create or update PR playground comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const pr_number = fs.readFileSync('./NR', 'utf8').trim(); | |
| const plugin_version = fs.readFileSync('./VERSION', 'utf8').trim(); | |
| const artifact_name = fs.readFileSync('./ARTIFACT', 'utf8').trim(); | |
| // Load the comment script | |
| const script = require('./.github/scripts/playground-comment.js'); | |
| // Set environment variables for the script | |
| process.env.PLUGIN_VERSION = plugin_version; | |
| process.env.ARTIFACT_NAME = artifact_name; | |
| const updatedContext = { | |
| repo: { | |
| owner: context.repo.owner, | |
| repo: context.repo.repo | |
| }, | |
| issue: { | |
| number: parseInt(pr_number, 10) | |
| }, | |
| runId: context.runId, | |
| payload: { | |
| pull_request: { | |
| number: parseInt(pr_number, 10), | |
| head: { | |
| sha: context.sha | |
| } | |
| } | |
| } | |
| }; | |
| await script.run({ github, context: updatedContext, core }); |