Skip to content

Commit 2794b71

Browse files
committed
update gh-action to sync
1 parent ad183e0 commit 2794b71

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

.github/workflows/sync-boilerplate-cha.yaml

+15-11
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
run: |
3535
git checkout main
3636
git pull origin main
37-
git cherry-pick 1c4b4c1eb436d27154e983d3c761632c4b40e029 || git cherry-pick --abort
37+
git cherry-pick 1c4b4c1eb436d27154e983d3c761632c4b40e029 ad183e0ba325628aad90b486fa415602c1fbf6d4 || git cherry-pick --abort
3838
3939
- name: Clone Create-Hyperweb-App Repo
4040
run: |
@@ -51,7 +51,9 @@ jobs:
5151
exit 1
5252
fi
5353
VERSION=$(jq -r .version ../create-hyperweb-app/templates/hyperweb/package.json)
54+
GIT_HEAD=$(jq -r .gitHead ../create-hyperweb-app/templates/hyperweb/package.json)
5455
echo "version=$VERSION" >> $GITHUB_OUTPUT
56+
echo "git_head=$GIT_HEAD" >> $GITHUB_OUTPUT
5557
5658
- name: Get GIT_HASH from Hyperweb-Boilerplate
5759
id: git_hash
@@ -63,13 +65,16 @@ jobs:
6365
run: |
6466
rsync -av --exclude='.git' ./ ../create-hyperweb-app/templates/hyperweb/ --delete
6567
66-
- name: Update Version in package.json
68+
- name: Update Version and GitHead in package.json
6769
run: |
6870
cd ../create-hyperweb-app
6971
if [ -f templates/hyperweb/package.json ]; then
7072
# Update the version in package.json (increment or set the value as needed)
7173
NEW_VERSION="${{ steps.get_version.outputs.version }}"
72-
jq ".version = \"$NEW_VERSION\"" templates/hyperweb/package.json > tmp.json && mv tmp.json templates/hyperweb/package.json
74+
GIT_HEAD="${{ steps.get_version.outputs.git_head }}"
75+
jq --arg version "$NEW_VERSION" --arg gitHead "$GIT_HEAD" \
76+
'if .gitHead == null then .gitHead = $gitHead else .gitHead end | .version = $version' \
77+
templates/hyperweb/package.json > tmp.json && mv tmp.json templates/hyperweb/package.json
7378
else
7479
echo "package.json not found!"
7580
exit 1
@@ -80,6 +85,7 @@ jobs:
8085
run: |
8186
cd ../create-hyperweb-app
8287
git add .
88+
git restore --staged templates/hyperweb/CHANGELOG.md
8389
if ! git diff-index --quiet HEAD; then
8490
SHORT_HASH="${{ steps.git_hash.outputs.git_hash }}"
8591
NEW_BRANCH="sync/hyperweb-boilerplate-update-${SHORT_HASH}-$(date +%Y%m%d%H%M)"
@@ -96,13 +102,11 @@ jobs:
96102
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
97103
-H "Accept: application/vnd.github.v3+json" \
98104
https://api.github.com/repos/hyperweb-io/create-hyperweb-app/pulls \
99-
-d @- << EOF
100-
{
101-
"title": "Sync boilerplate changes for commit ${NEW_BRANCH}",
102-
"head": "${NEW_BRANCH}",
105+
-d "$(echo '{
106+
"title": "Sync boilerplate changes for branch '"${NEW_BRANCH}"'",
107+
"head": "'"${NEW_BRANCH}"'",
103108
"base": "main",
104-
"body": "This PR contains the latest boilerplate changes from hyperweb-boilerplate for branch ${NEW_BRANCH}. Also includes updates from the changelog file."
105-
}
106-
EOF
109+
"body": "This PR contains the latest boilerplate changes from hyperweb-boilerplate for branch '"${NEW_BRANCH}"'. Also includes updates from the changelog file."
110+
}')"
107111
)
108-
echo "Pull request created: $PR_URL"
112+
echo "Pull request created: $PR_URL"

0 commit comments

Comments
 (0)