fix bump version ci #14
Workflow file for this run
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: Verify and Bump Version | |
on: | |
# push | |
pull_request: | |
types: [opened, reopened] | |
branches: | |
- main # Trigger the action on PRs targeting the main branch | |
jobs: | |
verify-and-bump: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the PR branch | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.head_ref }} | |
- name: Get version from PR branch | |
id: pr-version | |
run: | | |
PR_VERSION=$(jq -r '.version' apps/web/package.json) | |
echo "::set-output name=pr_version::${PR_VERSION}" | |
- name: Checkout the main branch | |
uses: actions/checkout@v3 | |
with: | |
ref: main | |
- name: Get version from main branch | |
id: main-version | |
run: | | |
MAIN_VERSION=$(jq -r '.version' apps/web/package.json) | |
echo "::set-output name=main_version::${MAIN_VERSION}" | |
- name: Compare versions | |
id: compare-versions | |
run: | | |
if [ "${{ steps.pr-version.outputs.pr_version }}" != "${{ steps.main-version.outputs.main_version }}" ]; then | |
echo "::set-output name=need_bump::'false'" | |
echo "The versions are different." | |
else | |
echo "::set-output name=need_bump::'true'" | |
echo "The versions are the same. Bump required." | |
fi | |
- name: Comment PR | |
if: contains(steps.compare-versions.outputs.need_bump, 'true') | |
uses: thollander/actions-comment-pull-request@v2 | |
with: | |
message: | | |
Please, update version of web project! :wave: | |
# - name: Checkout the PR branch | |
# uses: actions/checkout@v3 | |
# with: | |
# ref: ${{ github.head_ref }} | |
# fetch-depth: 0 | |
# - name: Bump version | |
# if: always() | |
# working-directory: apps/web | |
# run: npm version patch | |
# - name: Commit changes | |
# if: always() | |
# run: | | |
# git add apps/web/package.json | |
# git config user.name "GitHub Actions Bot" | |
# git config user.email "<>" | |
# git commit -m "Bump version in apps/web" | |
# git push |