Skip to content

Commit 3f9d95e

Browse files
authored
Merge pull request #9 from fr3nch13/fix-eq-error-for-priority
Update bash.yml
2 parents a8ba634 + 71853c3 commit 3f9d95e

6 files changed

Lines changed: 43 additions & 24 deletions

File tree

.github/workflows/bash.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ permissions:
1515
jobs:
1616
run_fail:
1717
name: Bash - Expect fail
18-
runs-on: ubuntu-latest
18+
runs-on: ubuntu-22.04
1919
steps:
2020
- name: Git checkout
2121
uses: actions/checkout@v3
@@ -26,11 +26,11 @@ jobs:
2626
- name: Run script expect fail
2727
#continue-on-error: true
2828
run: |
29-
./pushover.sh -v -t badtoken -u badkey -d baddevice -T Github Action Fail -m Github Action Fail || (( $? == 2 )) && exit 0 || exit $?
29+
./pushover.sh -v -t badtoken -u badkey -d baddevice -T Github Action Fail -m Github Action Fail || (( $? == 3 )) && exit 0 || exit $?
3030
3131
run_cli:
3232
name: Bash - Run with Arguments
33-
runs-on: ubuntu-latest
33+
runs-on: ubuntu-22.04
3434
steps:
3535
- name: Git checkout
3636
uses: actions/checkout@v3
@@ -44,7 +44,7 @@ jobs:
4444
4545
run_config:
4646
name: Bash - Run with Config File
47-
runs-on: ubuntu-latest
47+
runs-on: ubuntu-22.04
4848
steps:
4949
- name: Git checkout
5050
uses: actions/checkout@v3
@@ -62,5 +62,14 @@ jobs:
6262
- name: Validate with config
6363
run: ./pushover.sh -v -x -m Github Action Config
6464

65-
- name: Run script from config
66-
run: ./pushover.sh -v -p -2 -m Github Action Config
65+
# Eventually move these to a test script.
66+
- name: Run script from config, priority 2
67+
run: ./pushover.sh -v -m Github Action Config -p -2
68+
69+
- name: Run script from config, priority 1
70+
run: ./pushover.sh -v -m Github Action Config -p -1
71+
72+
- name: Run script with bad priority
73+
#continue-on-error: true
74+
run: |
75+
./pushover.sh -v -m Github Action Bad Priority -p A || (( $? == 4 )) && exit 0 || exit $?

.github/workflows/composer.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ permissions:
1414

1515
jobs:
1616
run_test:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-22.04
1818
strategy:
1919
matrix:
20-
# the Node.js versions to build on
20+
# the PHP versions to test on
2121
php: ['7.4', '8.0', '8.1', '8.2', 'latest']
2222
name: PHP - ${{ matrix.php }}
2323
steps:
@@ -45,5 +45,5 @@ jobs:
4545
- name: Run script via Composer
4646
run: composer run-script pushover-test
4747

48-
- name: Run script with Args via Composer
49-
run: composer run-script pushover -- -p -2 -m Composer Test Args ${{ matrix.php }}
48+
- name: Run script with Args via Composer, priority 1
49+
run: composer run-script pushover -- -m Composer Test Args ${{ matrix.php }} -p -1

.github/workflows/npm.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ permissions:
1414

1515
jobs:
1616
run_test:
17-
runs-on: ubuntu-latest
17+
runs-on: ubuntu-22.04
1818
strategy:
1919
matrix:
20-
# the Node.js versions to build on
20+
# the Node.js versions to test on
2121
node: [18, 20]
2222
name: Node - ${{ matrix.node }}
2323
steps:
@@ -48,8 +48,5 @@ jobs:
4848
- name: Run script via NPM
4949
run: npm run pushover-test
5050

51-
- name: Run script with Args via NPM
52-
run: npm run pushover -- -p -2 -m Node Test Args ${{ matrix.node }}
53-
54-
- name: Run via the bin setting
55-
run: npm exec pushover-bash -- -p -2 -m Node Test Args ${{ matrix.node }}
51+
- name: Run via the bin setting, priority 1
52+
run: npm exec pushover-bash -- -m Node Test Args ${{ matrix.node }} -p -1

.github/workflows/publish.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,12 @@ jobs:
6363
token: ${{ secrets.PUSH_TO_PROTECTED_BRANCH }}
6464
branch: main
6565
unprotect_reviews: true
66+
# This will bump the package.json, then create a draft release on github.
67+
# The draft release will update packagist (composer) when it's published.
6668
- name: Run release
6769
run: |
6870
npm whoami
6971
npm install
70-
# See ROOt/.release-it.sh
72+
# See ROOT/.release-it.sh
7173
# That defines how the release command behaves.
7274
npm run release -- --ci --verbose ${{ github.event.inputs.version }}${{ github.event.inputs.dry-run == 'true' && ' --dry-run' || '' }}

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[![CI Bash](https://github.com/fr3nch13/pushover-bash/actions/workflows/bash.yml/badge.svg)](https://github.com/fr3nch13/pushover-bash/actions/workflows/bash.yml)
2+
[![CI Composer](https://github.com/fr3nch13/pushover-bash/actions/workflows/composer.yml/badge.svg)](https://github.com/fr3nch13/pushover-bash/actions/workflows/composer.yml)
3+
[![CI NPM](https://github.com/fr3nch13/pushover-bash/actions/workflows/npm.yml/badge.svg)](https://github.com/fr3nch13/pushover-bash/actions/workflows/npm.yml)
4+
15
# Pushover Bash Script
26
A Bash shell script to send pushover notifications. A [Pushover account](https://pushover.net/) is required to use this script.
37

@@ -96,6 +100,7 @@ title="title for specific user"
96100
## Support
97101
- For PHP Composer based projects, see [COMPOSER.md](COMPOSER.md)
98102
- For Node.js/NPM based projects, see [NPM.md](NPM.md)
103+
- Currently working on Python's PyPi
99104

100105
## Examples
101106
Send a simple "This is a test" message to all devices using the stored configuration in either **/etc/default/pushover-config**, **$HOME/.pushover/pushover-config**, or **./pushover-config**

pushover.sh

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env bash
22

3-
set -o errexit
43
set -o nounset
54

65
readonly API_URL="https://api.pushover.net/1/messages.json"
@@ -203,10 +202,17 @@ do
203202
myargs[${varname}]=''
204203
fi
205204
if [ ${1:0:1} != '-' ]; then
206-
myargs[${varname}]="${myargs[${varname}]} ${1}"
207-
# priority
208-
elif [ ${varname} == 'priority' ]; then
209-
myargs[${varname}]=${1}
205+
# priority
206+
if [ ${varname} == 'priority' ]; then
207+
pval=`printf -v int '%d\n' "${1}" 2>/dev/null`
208+
if [ $? -ne 0 ]; then
209+
echo "Priority must be an integer. You gave: ${1}"
210+
exit 4
211+
fi
212+
myargs[${varname}]=${pval}
213+
else
214+
myargs[${varname}]="${myargs[${varname}]} ${1}"
215+
fi
210216
fi
211217
fi
212218
shift
@@ -320,7 +326,7 @@ fi
320326

321327
# the resonse from pushover is a failure when the status is 0
322328
if echo ${response} | grep -q '"status":0,'; then
323-
exit 2
329+
exit 3
324330
fi
325331

326332
exit 0

0 commit comments

Comments
 (0)