From e82d92f60286ec60f481260b641e470f1be368ec Mon Sep 17 00:00:00 2001 From: costdev Date: Fri, 8 Nov 2024 03:00:39 +0000 Subject: [PATCH 1/7] Add workflow. --- .github/workflows/playground-blueprint.yml | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/playground-blueprint.yml diff --git a/.github/workflows/playground-blueprint.yml b/.github/workflows/playground-blueprint.yml new file mode 100644 index 0000000..45387d5 --- /dev/null +++ b/.github/workflows/playground-blueprint.yml @@ -0,0 +1,39 @@ +name: Update Blueprint Blueprint with Repository and Branch + +on: + push: + +jobs: + update-blueprint: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set Branch or Tag Name + id: branch-name + run: | + if [ "${{ github.ref_type }}" == "branch" ]; then + echo "CURRENT_REF=${{ github.ref_name }}" >> $GITHUB_ENV + elif [ "${{ github.ref_type }}" == "tag" ]; then + echo "CURRENT_REF=${{ github.ref_name }}" >> $GITHUB_ENV + fi + + - name: Update Blueprint JSON + run: | + jq --tab '.plugins[0] |= "https://github-proxy.com/proxy/?repo='$GITHUB_REPOSITORY'&branch='$CURRENT_REF'"' assets/playground/blueprint.json > assets/playground/blueprint.json.tmp + mv assets/playground/blueprint.json.tmp assets/playground/blueprint.json + + - name: Commit and Push Changes + run: | + if git diff --cached --quiet; then + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add assets/playground/blueprint.json + git commit -m "Update blueprint.json for branch/tag ${{ env.name }}" + git push + fi + env: + name: ${{ env.name }} + From 5b0aaee87ae9ae6c2df12bacd4318ec31a4caa84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 03:15:12 +0000 Subject: [PATCH 2/7] Update blueprint.json for branch/tag --- assets/playground/blueprint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/playground/blueprint.json b/assets/playground/blueprint.json index d9e8453..86d8072 100644 --- a/assets/playground/blueprint.json +++ b/assets/playground/blueprint.json @@ -17,7 +17,7 @@ "blogname": "AspireUpdate Demo Site" }, "plugins": [ - "https://github-proxy.com/proxy/?repo=AspirePress/AspireUpdate&branch=playground-ready", + "https://github-proxy.com/proxy/?repo=costdev/AspireUpdate&branch=use_dynamic_references_in_playground_blueprint", "error-log-viewer", "plugin-check" ], From cbd4cf8dc387e03890d86402738fb5b32061ec23 Mon Sep 17 00:00:00 2001 From: costdev Date: Fri, 8 Nov 2024 03:16:12 +0000 Subject: [PATCH 3/7] Test with already changed blueprint. --- .github/workflows/playground-blueprint.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/playground-blueprint.yml b/.github/workflows/playground-blueprint.yml index 45387d5..4bd67ce 100644 --- a/.github/workflows/playground-blueprint.yml +++ b/.github/workflows/playground-blueprint.yml @@ -25,13 +25,17 @@ jobs: jq --tab '.plugins[0] |= "https://github-proxy.com/proxy/?repo='$GITHUB_REPOSITORY'&branch='$CURRENT_REF'"' assets/playground/blueprint.json > assets/playground/blueprint.json.tmp mv assets/playground/blueprint.json.tmp assets/playground/blueprint.json - - name: Commit and Push Changes + - name: Commit and Push Changes1 run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + + git add assets/playground/blueprint.json + if git diff --cached --quiet; then - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git add assets/playground/blueprint.json - git commit -m "Update blueprint.json for branch/tag ${{ env.name }}" + echo "No changes to commit." + else + git commit -m "Update blueprint.json for ${{ env.name }}" git push fi env: From 62cdac48428deb39c9e1fc5cc98e445160dc238c Mon Sep 17 00:00:00 2001 From: costdev Date: Fri, 8 Nov 2024 03:18:40 +0000 Subject: [PATCH 4/7] Test again with already changed blueprint. --- .github/workflows/playground-blueprint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/playground-blueprint.yml b/.github/workflows/playground-blueprint.yml index 4bd67ce..d8150ae 100644 --- a/.github/workflows/playground-blueprint.yml +++ b/.github/workflows/playground-blueprint.yml @@ -25,7 +25,7 @@ jobs: jq --tab '.plugins[0] |= "https://github-proxy.com/proxy/?repo='$GITHUB_REPOSITORY'&branch='$CURRENT_REF'"' assets/playground/blueprint.json > assets/playground/blueprint.json.tmp mv assets/playground/blueprint.json.tmp assets/playground/blueprint.json - - name: Commit and Push Changes1 + - name: Commit and Push Changes run: | git config --global user.name "github-actions[bot]" git config --global user.email "github-actions[bot]@users.noreply.github.com" From ccdfbe2be0998cbbbe6e6470b32468eb3c43f3b8 Mon Sep 17 00:00:00 2001 From: costdev Date: Fri, 8 Nov 2024 03:19:40 +0000 Subject: [PATCH 5/7] Change blueprint back to force another rewrite. --- .github/workflows/playground-blueprint.yml | 2 +- assets/playground/blueprint.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/playground-blueprint.yml b/.github/workflows/playground-blueprint.yml index d8150ae..82776ca 100644 --- a/.github/workflows/playground-blueprint.yml +++ b/.github/workflows/playground-blueprint.yml @@ -35,7 +35,7 @@ jobs: if git diff --cached --quiet; then echo "No changes to commit." else - git commit -m "Update blueprint.json for ${{ env.name }}" + git commit -m "Update blueprint.json for $CURRENT_REF" git push fi env: diff --git a/assets/playground/blueprint.json b/assets/playground/blueprint.json index 86d8072..d9e8453 100644 --- a/assets/playground/blueprint.json +++ b/assets/playground/blueprint.json @@ -17,7 +17,7 @@ "blogname": "AspireUpdate Demo Site" }, "plugins": [ - "https://github-proxy.com/proxy/?repo=costdev/AspireUpdate&branch=use_dynamic_references_in_playground_blueprint", + "https://github-proxy.com/proxy/?repo=AspirePress/AspireUpdate&branch=playground-ready", "error-log-viewer", "plugin-check" ], From 689b86f93cefc0f5292d11bb069c6b1680e91c38 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 8 Nov 2024 03:20:55 +0000 Subject: [PATCH 6/7] Update blueprint.json for use_dynamic_references_in_playground_blueprint --- assets/playground/blueprint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/playground/blueprint.json b/assets/playground/blueprint.json index d9e8453..86d8072 100644 --- a/assets/playground/blueprint.json +++ b/assets/playground/blueprint.json @@ -17,7 +17,7 @@ "blogname": "AspireUpdate Demo Site" }, "plugins": [ - "https://github-proxy.com/proxy/?repo=AspirePress/AspireUpdate&branch=playground-ready", + "https://github-proxy.com/proxy/?repo=costdev/AspireUpdate&branch=use_dynamic_references_in_playground_blueprint", "error-log-viewer", "plugin-check" ], From 40e536be45ab084bf371e9b733b3760df2d60594 Mon Sep 17 00:00:00 2001 From: costdev Date: Fri, 8 Nov 2024 03:25:32 +0000 Subject: [PATCH 7/7] Workflows: Add a Playground comment to new PRs. --- .../workflows/add-pr-playground-comment.yml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .github/workflows/add-pr-playground-comment.yml diff --git a/.github/workflows/add-pr-playground-comment.yml b/.github/workflows/add-pr-playground-comment.yml new file mode 100644 index 0000000..5fc17a9 --- /dev/null +++ b/.github/workflows/add-pr-playground-comment.yml @@ -0,0 +1,29 @@ +name: Add PR Playground Comment + +on: + pull_request: + types: [opened] # Trigger when a PR is first opened + +jobs: + comment-pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Read and Base64 encode blueprint.json + id: encode_blueprint + run: | + # Read the content of blueprint.json and base64 encode it + encoded=$(base64 -w 0 assets/playground/blueprint.json) + echo "Encoded Blueprint: $encoded" + echo "encoded=$encoded" >> $GITHUB_ENV + + - name: Add PR comment + uses: peter-evans/create-or-update-comment@v2 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + A link to the playground with the base64-encoded blueprint is available: + [Playground Link](https://playground.wordpress.net/#${{ env.encoded }})