Skip to content

Commit a31148a

Browse files
committed
add gh-action for cha-sync-branch
1 parent 1c4b4c1 commit a31148a

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
name: Sync Boilerplate to Create-Hyperweb-App
2+
3+
on:
4+
push:
5+
branches:
6+
- cha-sync-branch
7+
workflow_run:
8+
workflows: ["Build"]
9+
types:
10+
- completed
11+
12+
jobs:
13+
sync-repo:
14+
runs-on: ubuntu-latest
15+
steps:
16+
# Step 1: Checkout the hyperweb-boilerplate repo (private access)
17+
- name: Checkout Boilerplate Repo
18+
uses: actions/checkout@v2
19+
with:
20+
repository: hyperweb-io/hyperweb-boilerplate
21+
token: ${{ secrets.PAT_TOKEN }} # Use PAT for private repo access
22+
fetch-depth: 0
23+
24+
# Step 2: Checkout the cha-sync-branch from hyperweb-boilerplate
25+
- name: Checkout CHA Sync Branch
26+
run: |
27+
git checkout cha-sync-branch
28+
git pull origin cha-sync-branch
29+
30+
# Step 3: Cherry-pick the specific commit into the main branch
31+
- name: Cherry-pick the commit
32+
run: |
33+
git checkout main
34+
git pull origin main
35+
git cherry-pick <commit-hash> || git cherry-pick --abort
36+
37+
# Step 4: Clone the create-hyperweb-app repo (private access)
38+
- name: Clone Create-Hyperweb-App Repo
39+
run: |
40+
git clone https://github.com/hyperweb-io/create-hyperweb-app.git ../create-hyperweb-app
41+
cd ../create-hyperweb-app
42+
git checkout main
43+
cd -
44+
45+
# Step 5: Sync changes from hyperweb-boilerplate to create-hyperweb-app
46+
- name: Copy and Apply Changes to Create-Hyperweb-App
47+
run: |
48+
rsync -av --exclude='.git' --exclude-from='.github/workflows/sync-boilerplate-cha.yaml' ./ ../create-hyperweb-app/templates/hyperweb/ --delete
49+
50+
# Step 6: Extract the version from the package.json
51+
- name: Get Version from package.json
52+
id: get_version
53+
run: |
54+
if [ ! -f ../create-hyperweb-app/cha/package.json ]; then
55+
echo "package.json not found!"
56+
exit 1
57+
fi
58+
VERSION=$(jq -r .version ../create-hyperweb-app/cha/package.json)
59+
echo "version=$VERSION" >> $GITHUB_OUTPUT
60+
61+
# Step 7: Update the version in package.json of create-hyperweb-app
62+
- name: Update Version in package.json
63+
run: |
64+
cd ../create-hyperweb-app
65+
if [ -f cha/package.json ]; then
66+
# Update the version in package.json (increment or set the value as needed)
67+
NEW_VERSION="${{ steps.get_version.outputs.version }}"
68+
jq ".version = \"$NEW_VERSION\"" cha/package.json > tmp.json && mv tmp.json cha/package.json
69+
else
70+
echo "package.json not found!"
71+
exit 1
72+
fi
73+
74+
# Step 8: Copy the changelog from CHA folder
75+
- name: Get Changelog File
76+
run: |
77+
if [ -f ../create-hyperweb-app/cha/CHANGELOG.md ]; then
78+
cp ../create-hyperweb-app/cha/CHANGELOG.md ../create-hyperweb-app/templates/hyperweb/
79+
else
80+
echo "CHANGELOG.md not found!"
81+
fi
82+
83+
# Step 9: Commit and push changes to a new branch in create-hyperweb-app
84+
- name: Commit and Push Changes
85+
run: |
86+
cd ../create-hyperweb-app
87+
git add .
88+
if ! git diff-index --quiet HEAD; then
89+
NEW_BRANCH="sync/hyperweb-boilerplate-update-${{ steps.get_version.outputs.version }}-$(date +%Y%m%d%H%M)"
90+
git checkout -b $NEW_BRANCH
91+
git commit -m "Sync changes from hyperweb-boilerplate for version ${{ steps.get_version.outputs.version }}"
92+
git push origin $NEW_BRANCH
93+
fi
94+
95+
# Step 10: Create a pull request in create-hyperweb-app
96+
- name: Create Pull Request
97+
uses: peter-evans/create-pull-request@v5
98+
with:
99+
token: ${{ secrets.PAT_TOKEN }} # Use PAT for private repo access
100+
repository: hyperweb-io/create-hyperweb-app
101+
base: main
102+
head: sync/hyperweb-boilerplate-update-${{ steps.get_version.outputs.version }}-$(date +%Y%m%d%H%M)
103+
title: "Sync boilerplate changes for version ${{ steps.get_version.outputs.version }}"
104+
body: |
105+
This PR contains the latest boilerplate changes from hyperweb-boilerplate for version ${{ steps.get_version.outputs.version }}.
106+
Also includes updates from the changelog file.

0 commit comments

Comments
 (0)