Skip to content

Commit

Permalink
Use the uploaded artifact url as the blueprint url instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ingeniumed committed Feb 4, 2025
1 parent 6043101 commit be2de98
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
32 changes: 15 additions & 17 deletions .github/workflows/build-live-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,35 +46,33 @@ jobs:
run: |
echo "Generating zip file..."
cd "$GITHUB_WORKSPACE" || exit
cd ../
zip -q -r -9 "$ZIP_NAME" "remote-data-blocks/"
mkdir "$GITHUB_WORKSPACE/zips"
mv "$ZIP_NAME" "$GITHUB_WORKSPACE/zips/"
mkdir -p "$GITHUB_WORKSPACE/unzips/remote-data-blocks"
cd "$GITHUB_WORKSPACE/zips"
npm run plugin-zip
mv remote-data-blocks.zip "$ZIP_NAME"
mkdir "zips"
mv "$ZIP_NAME" "zips/"
mkdir -p "unzips/remote-data-blocks"
cd "zips"
unzip -qq "$ZIP_NAME"
mv "$ZIP_NAME" "remote-data-blocks"
mv "$GITHUB_WORKSPACE/zips/remote-data-blocks" "$GITHUB_WORKSPACE/unzips/remote-data-blocks/remote-data-blocks"
- name: Create plugins artifact
uses: actions/upload-artifact@v4
with:
name: remote-data-blocks-${{ github.event.pull_request.number }}
path: zips
# Only need to retain for a day since the beta builder slurps it up to distribute.
retention-days: 1

- name: Create playground artifact
id: create-playground-artifact-step
uses: actions/upload-artifact@v4
with:
name: remote-data-blocks-${{ github.event.pull_request.number }}
path: unzips/remote-data-blocks
retention-days: 30
retention-days: 2
if-no-files-found: 'error'
overwrite: true

- name: Output artifact ID
run: echo 'Artifact ID is ${{ steps.create-playground-artifact-step.outputs.artifact-url }}'

- name: Comment on PR with WordPress Playground details
uses: actions/github-script@v7
if: ! github.event.pull_request.head.repo.fork
with:
script: |
const { run } = require('./.github/workflows/scripts/generate-playground-blueprint');
run({ github, context, core });
run({ github, context, core, artifactUrl: ${{ steps.create-playground-artifact-step.outputs.artifact-url }} });
8 changes: 4 additions & 4 deletions .github/workflows/scripts/generate-playground-blueprint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const https = require( 'https' );

const generateWordpressPlaygroundBlueprint = ( prNumber ) => {
const generateWordpressPlaygroundBlueprint = ( prNumber, artifactUrl ) => {
const defaultSchema = {
meta: {
title: `Remote Data Blocks - PR #${ prNumber }`,
Expand Down Expand Up @@ -41,7 +41,7 @@ const generateWordpressPlaygroundBlueprint = ( prNumber ) => {
pluginData: {
caption: 'Installing Remote Data Blocks',
resource: 'url',
url: `https://github-proxy.com/proxy/?repo=Automattic/remote-data-blocks&artifact=remote-data-blocks-${ prNumber }.zip`,
url: `${ artifactUrl }`,
},
options: {
activate: true,
Expand All @@ -54,7 +54,7 @@ const generateWordpressPlaygroundBlueprint = ( prNumber ) => {
return defaultSchema;
};

async function run( { github, context, core } ) {
async function run( { github, context, core, artifactUrl } ) {
const commentInfo = {
owner: context.repo.owner,
repo: context.repo.repo,
Expand All @@ -75,7 +75,7 @@ async function run( { github, context, core } ) {
}
}

const defaultSchema = generateWordpressPlaygroundBlueprint( context.issue.number );
const defaultSchema = generateWordpressPlaygroundBlueprint( context.issue.number, artifactUrl );

const url = `https://playground.wordpress.net/#${ JSON.stringify(
defaultSchema
Expand Down

0 comments on commit be2de98

Please sign in to comment.