Create PR for Release Branch #9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Create PR for Release Branch | |
on: | |
create: | |
branches: | |
- '**' | |
jobs: | |
create_release_branch: | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/heads/release-') | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set Version as env var | |
run: | | |
branch_name=$(echo ${{ github.ref }} | sed 's/refs\/heads\///') | |
VERSION=${branch_name#release-} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: 'yarn' | |
- name: Run version | |
run: yarn version --new-version $VERSION --no-git-tag-version | |
- name: Commit changes | |
run: | | |
git config --local user.email user.email "hello@polybase.xyz" | |
git config --local user.name "Polybase CI" | |
git add . | |
git commit -m "Bump version" || echo "No changes to commit" | |
git push | |
- name: Create Pull Request | |
env: | |
GITHUB_TOKEN: ${{ secrets.ADMIN_TOKEN }} | |
run: | | |
branch_name=$(echo ${{ github.ref }} | sed 's/refs\/heads\///') | |
curl -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/repos/${{ github.repository }}/pulls \ | |
-d '{ | |
"title": "Release 'v$VERSION'", | |
"body": "This is an automated PR for release '$VERSION'", | |
"head": "'$branch_name'", | |
"base": "main" | |
}' |