Skip to content

Commit

Permalink
Merge pull request #17 from rlabinc/main
Browse files Browse the repository at this point in the history
Script version auto updater
  • Loading branch information
origamiofficial committed Aug 9, 2023
2 parents c2954f4 + 5f5d9f0 commit 4955b1a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/update-script-version.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Bump Script Version

on:
push:
pull_request:

jobs:
update_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2
# Check if ngrok-plex.py has been modified since the last commit
- name: Update Script Version
id: update-script
env:
GIT_AUTH: ${{ secrets.GIT_AUTH }}
run: |
if ! git diff HEAD~1 --name-only | grep -q "ngrok-plex.py"; then
echo "No changes to ngrok-plex.py since last commit"
exit 0
else
echo "ngrok-plex.py file has been modified"
# Get the previous SCRIPT_VERSION from the last commit
PREVIOUS_SCRIPT_VERSION=$(git show HEAD~:ngrok-plex.py | grep "SCRIPT_VERSION = " | cut -d "=" -f 2 | tr -d " '\"")
# Get the current SCRIPT_VERSION from ngrok-plex.py
SCRIPT_VERSION=$(grep "SCRIPT_VERSION = " ngrok-plex.py | cut -d "=" -f 2 | tr -d " '\"")
# Check if the SCRIPT_VERSION has been manually updated
if [[ "$SCRIPT_VERSION" != "$PREVIOUS_SCRIPT_VERSION" ]]; then
echo "SCRIPT_VERSION has been manually updated"
exit 0
else
echo 'SCRIPT_VERSION has NOT been manually updated'
# Increment the SCRIPT_VERSION by 0.1
NEW_SCRIPT_VERSION=$(awk -v x=$SCRIPT_VERSION 'BEGIN { printf "%.1f", x+0.1 }')
# Update the SCRIPT_VERSION in ngrok-plex.py
sed -i "s/$SCRIPT_VERSION/$NEW_SCRIPT_VERSION/g" ngrok-plex.py
if [[ $(git status) == *"nothing to commit, working tree clean"* ]]; then
echo "Nothing to commit, working tree clean"
exit 0
fi
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git remote set-url origin https://${{ secrets.GIT_AUTH }}@github.com/origamiofficial/docker-ngrok-plex.git
git add ngrok-plex.py
git commit -m "Bump Script Version"
git push
fi
fi
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ Container images are configured using parameters passed at runtime (such as thos
* Client IP will always show as `localhost`.
* No bandwidth guarantees.

## Contribution
There is no need to update the script version if you have made changes – it will be updated automatically.

## Github Repository
https://github.com/origamiofficial/ngrok-plex

Expand Down
3 changes: 3 additions & 0 deletions ngrok-plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import time
import socket

# Script version
SCRIPT_VERSION = "1.1"

###This script hashes out the duckdns portion.

# please make sure to install PlexAPI via pip, "pip install PlexAPI"
Expand Down

0 comments on commit 4955b1a

Please sign in to comment.