Skip to content

Commit

Permalink
test version-update github action
Browse files Browse the repository at this point in the history
  • Loading branch information
Yen Truong committed Nov 24, 2021
1 parent 641cc20 commit 62968f5
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/version-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Update package version for release & hotfix branches

on:
create:
branches: [release/*, hotfix/*]

permissions:
contents: write
pull-requests: write

jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: extract package version
id: vars
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
PACKAGE_VERSION="${GITHUB_REF##*/}"
echo ::set-output name=branch::${BRANCH_NAME}
echo ::set-output name=version::${PACKAGE_VERSION}
if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
then
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
npm version ${PACKAGE_VERSION}
git push -u origin HEAD:"dev/update-version-${PACKAGE_VERSION}"
else
echo "Branch name ${BRANCH_NAME} does not have the correct format with package version."
exit 1
fi
- uses: repo-sync/pull-request@v2
with:
source_branch: "dev/update-version-${{ steps.vars.outputs.version }}"
destination_branch: "${{ steps.vars.outputs.branch }}"
pr_title: "Update Package Version to ${{ steps.vars.outputs.version }}"
pr_body: "*An automated PR*"
github_token: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 62968f5

Please sign in to comment.