Skip to content

Commit

Permalink
Test reusable workflow w/package v0.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
nmanu1 committed Mar 23, 2022
1 parent 1d3351a commit bef4aad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 58 deletions.
59 changes: 4 additions & 55 deletions .github/workflows/version-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,59 +4,8 @@ on:
push:
branches: [release/*, hotfix/*, test/*]

permissions:
contents: write
pull-requests: write

jobs:
update-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: update package version
id: vars
run: |
BRANCH_NAME="${GITHUB_REF#refs/heads/}"
PACKAGE_VERSION="${GITHUB_REF##*/}"
echo ${BRANCH_NAME}
echo ::set-output name=branch::${BRANCH_NAME}
if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?$ ]]
then
if [[ $PACKAGE_VERSION =~ ^v[0-9]+\.[0-9]+$ ]]
then
PACKAGE_VERSION="${PACKAGE_VERSION}.0"
fi
echo ${PACKAGE_VERSION}
echo ::set-output name=version::${PACKAGE_VERSION}
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
if npm --no-git-tag-version version ${PACKAGE_VERSION} &> temp-npm-version.txt
then
echo ::set-output name=should_create_pr::1
git add package.json package-lock.json
git commit -m ${PACKAGE_VERSION}
git push -u origin HEAD:"dev/update-version-${PACKAGE_VERSION}"
exit 0
fi
echo ::set-output name=should_create_pr::0
if grep -q 'npm ERR! Version not changed' temp-npm-version.txt
then
echo "Package version is already in sync with branch name."
exit 0
fi
cat temp-npm-version.txt
exit 1
else
echo "Branch name ${BRANCH_NAME} does not have the correct format with package version."
exit 1
fi
- name: create version update pr
if: steps.vars.outputs.should_create_pr == 1
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 which updates the version number in package.json and package-lock.json files*"
github_token: ${{ secrets.GITHUB_TOKEN }}
call_version_update:
uses: yext/answers-headless/.github/workflows/version_update_reuse.yml@dev/test-reusable-workflows
secrets:
caller_github_token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yext/answers-search-ui",
"version": "1.12.2",
"version": "0.1.2",
"description": "Javascript Answers Programming Interface",
"main": "dist/answers-umd.js",
"repository": {
Expand Down

0 comments on commit bef4aad

Please sign in to comment.