Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use dynamic references in playground blueprint #161

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/add-pr-playground-comment.yml
Original file line number Diff line number Diff line change
@@ -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 }})
43 changes: 43 additions & 0 deletions .github/workflows/playground-blueprint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
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: |
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
echo "No changes to commit."
else
git commit -m "Update blueprint.json for $CURRENT_REF"
git push
fi
env:
name: ${{ env.name }}

2 changes: 1 addition & 1 deletion assets/playground/blueprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
],
Expand Down