Skip to content

Commit

Permalink
Support to pull request event
Browse files Browse the repository at this point in the history
-> Added support to pull_request event
-> Updated ReadMe file
  • Loading branch information
vinodhd-hrbl committed Nov 5, 2019
1 parent ae2e823 commit 73140c6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Bump-N-Tag Version
GitHub Action program to handle application version file like auto-increment of version number.
GitHub Action program to handle application version file like auto-increment of version number based on GitHub events. This action program supports "push" and "pull-request" events.

## Inputs

Expand All @@ -25,17 +25,11 @@ VERSION 1.2.4.55
```


## Outputs

### `app_version`

Output parameter to access Updated version.

## Example usage

```
name: App Version Actions
on: [push]
on: [push, pull_request] # Recommended to use either of one event
jobs:
Version-check:
Expand Down
30 changes: 24 additions & 6 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
#!/bin/sh -l
set -e

file_name=$1
tag_version=$2
echo "\nInput file name: $file_name : $tag_version"

([ -z "$GITHUB_ONLY_ON_COMMIT" ]) || exit 0
echo "Git Head Ref: ${GITHUB_HEAD_REF}"
echo "Git Base Ref: ${GITHUB_BASE_REF}"
echo "Git Event Name: ${GITHUB_EVENT_NAME}"

echo "\nStarting Git Operations"
git config --global user.email "[email protected]"
git config --global user.name "Bump-N-Tag App"

github_ref=""

if test "${GITHUB_EVENT_NAME}" = "push"
then
github_ref=${GITHUB_REF}
else
github_ref=${GITHUB_HEAD_REF}
git checkout $github_ref
fi


echo "Git Checkout"

if test -f $file_name; then
content=$(cat $file_name)
Expand Down Expand Up @@ -45,16 +65,14 @@ echo "\nUpdated version: $newver"
newcontent=$(echo ${content/$oldver/$newver})
echo $newcontent > $file_name

echo "\nStarting Git Operations"
git config --global user.email "[email protected]"
git config --global user.name "Bump-N-Tag App"

git add -A
git commit -m "Incremented to ${newver}" -m "[skip ci]"
([ -n "$tag_version" ] && [ "$tag_version" = "true" ]) && (git tag -a "${newver}" -m "[skip ci]") || echo "No tag created"

git show-ref
git push --follow-tags "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:${GITHUB_REF}
echo "Git Push"

git push --follow-tags "https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:$github_ref


echo "\nEnd of Action\n\n"
Expand Down

0 comments on commit 73140c6

Please sign in to comment.