Closed ipajen closed 1 day ago
How would one dynamically alter the blueprint based on the branch name?
Only way I see is to do a search and replace via regex in actions (unless there is some branch shortcodes in GIT). Its way way easier to update blueprint once when a new branch is created though.
Should we change this to won't fix or attempt search and replace in git action or is there another solution?
Could it work with this AI suggestion?
To make the blueprint.json dynamically fetch the appropriate branch or release tag, you can use a GitHub Action to automate the update of branch in the URL depending on the branch or tag being merged. This can be achieved by setting up a workflow that detects the branch or tag and replaces "playground-ready" in the blueprint with the correct branch or tag name.
Here’s how you can do it:
Here’s an example workflow for this:
name: Update Blueprint Branch
on: push: branches:
jobs: update-blueprint: runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set Branch or Tag Name
id: branch-name
run: |
# Get the branch name or tag name and store it in an environment variable
if [ "${{ github.ref_type }}" == "branch" ]; then
echo "name=${{ github.ref_name }}" >> $GITHUB_ENV
elif [ "${{ github.ref_type }}" == "tag" ]; then
echo "name=${{ github.ref_name }}" >> $GITHUB_ENV
fi
- name: Update Blueprint JSON
run: |
# Use `jq` to edit JSON in place (ensure jq is installed in your runner)
jq '.plugins[0] |= "https://github-proxy.com/proxy/?repo=AspirePress/AspireUpdate&branch=${name}"' 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
git commit -m "Update blueprint.json for branch/tag ${{ env.name }}"
git push
env:
name: ${{ env.name }}
Explanation:
• Step 1: Checkout code – This step checks out the repository.
• Step 2: Set Branch or Tag Name – This identifies whether the push was on a branch or tag and stores that name in the environment variable name.
• Step 3: Update Blueprint JSON – This uses the jq command to modify blueprint.json, replacing "playground-ready" with the detected branch or tag name. jq allows us to modify JSON files from the command line.
• Step 4: Commit and Push Changes – This commits the updated blueprint.json back to the repository.
This setup will automatically update blueprint.json to point to the appropriate branch or tag on any push to the specified branches or tags, making it more adaptable and reducing the need for manual updates.
Looks totally feasible, don't you love AI? Want to create a PR around it?
Looks totally feasible, don't you love AI? Want to create a PR around it?
I pass, I better stick to testing ;)
The AI-generated workflow was close!
I just needed to:
jq
commandreleases/
branch pattern and use the same tags
format as the releases.yml
workflow.@asirota Can this issue be reopened? A PR to fix the bug on this is already attached.
Done
Thanks @asirota! The PR is ready for review whenever you have time.
@asirota So while the last problem has been fixed, the next one arose: main
is a protected branch, so can only be changed by merging a PR into it.
I propose that we:
main
branch.main
from on.push.branches
in the workflow YML file.That way, main
just works, and when we merge to playground-ready
, since it's not protected, the workflow will run and update its blueprint from main
to playground-ready
Sound good?
Sounds fine. Do you know where to make the change in blueprint.json. It's pretty obvious but let me know if you want me to do that.
Thanks! Yeah I know where to make the change 👍
Change blueprint to based on the branch name dynamically. Probably a GitHub action would do this on a merge for all bransch and release tags
The current blueprint for the playground is hardcoded to retrieve the AU plugin from the playground-ready branch. Change so it point to itself.
https://github.com/aspirepress/AspireUpdate/blob/main/assets/playground/blueprint.json
This change would allow for easier testing of older releases in relation to specific issues across all branches on playground.
https://aspirepress.slack.com/archives/C07Q88M2KQF/p1730827139397469