Skip to content

Commit

Permalink
try to create pr with gh-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 committed Oct 17, 2024
1 parent 2ed5067 commit e2e855b
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions .github/workflows/sync-boilerplate-cha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ jobs:
VERSION=$(jq -r .version ../create-hyperweb-app/templates/hyperweb/package.json)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Get GIT_HASH from Hyperweb-Boilerplate
id: git_hash
run: |
SHORT_HASH=$(git -C ../hyperweb-boilerplate rev-parse --short HEAD)
echo "git_hash=$SHORT_HASH" >> $GITHUB_OUTPUT
- name: Copy and Apply Changes to Create-Hyperweb-App
run: |
rsync -av --exclude='.git' ./ ../create-hyperweb-app/templates/hyperweb/ --delete
Expand All @@ -70,30 +76,33 @@ jobs:
fi
- name: Commit and Push Changes
id: push_changes
run: |
cd ../create-hyperweb-app
# Get the short commit hash from the hyperweb-boilerplate repository
SHORT_HASH=$(git -C ../hyperweb-boilerplate rev-parse --short HEAD)
# Add changes
git add .
# Check if there are any changes to commit
if ! git diff-index --quiet HEAD; then
SHORT_HASH="${{ steps.git_hash.outputs.git_hash }}"
NEW_BRANCH="sync/hyperweb-boilerplate-update-${SHORT_HASH}-$(date +%Y%m%d%H%M)"
git checkout -b $NEW_BRANCH
git commit -m "Sync changes from hyperweb-boilerplate for commit ${SHORT_HASH}"
git push origin $NEW_BRANCH
echo "new_branch=$NEW_BRANCH" >> $GITHUB_OUTPUT
fi
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.PAT_TOKEN }} # Use PAT for private repo access
repository: hyperweb-io/create-hyperweb-app
base: main
head: sync/hyperweb-boilerplate-update-${{ steps.get_version.outputs.version }}-$(date +%Y%m%d%H%M)
title: "Sync boilerplate changes for version ${{ steps.get_version.outputs.version }}"
body: |
This PR contains the latest boilerplate changes from hyperweb-boilerplate for version ${{ steps.get_version.outputs.version }}.
Also includes updates from the changelog file.
run: |
NEW_BRANCH=${{ steps.push_changes.outputs.new_branch }}
PR_URL=$(curl -s -X POST \
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/hyperweb-io/create-hyperweb-app/pulls \
-d @- << EOF
{
"title": "Sync boilerplate changes for commit ${NEW_BRANCH}",
"head": "${NEW_BRANCH}",
"base": "main",
"body": "This PR contains the latest boilerplate changes from hyperweb-boilerplate for branch ${NEW_BRANCH}. Also includes updates from the changelog file."
}
EOF
)
echo "Pull request created: $PR_URL"

0 comments on commit e2e855b

Please sign in to comment.