Skip to content

Update Nomad Version #1173

Update Nomad Version

Update Nomad Version #1173

Workflow file for this run

name: Update Nomad Version
on:
schedule:
- cron: "0 9 * * *"
jobs:
update_nomad_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 0
- name: Update Nomad Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd ./packer/scripts
CURRENT=$(cat install_nomad.sh | grep "NOMAD_VERSION=" | awk -F '=' '{print $2}')
LATEST=$(curl --silent https://releases.hashicorp.com/index.json | jq -r '.nomad.versions | keys | .[]' | grep -v "-" | grep -v "+" | sort --version-sort | tail -n 1)
if [ "$CURRENT" != "$LATEST" ]; then
echo "Nomad version $CURRENT is out-of-date, updating to $LATEST"
# configure git
git config user.name "Nomad Update Bot"
git config user.email "[email protected]"
git remote set-url origin "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY"
# update install script
sed -i "s/$CURRENT/$LATEST/g" install_nomad.sh
# update README
cd -
sed -i "s/$CURRENT/$LATEST/g" README.md
# rest of git workflow
git add .
git commit -m "nomad-update-bot: update version from $CURRENT to $LATEST" || exit 1
git status
git push origin HEAD:master
else
echo "Nomad version $CURRENT is already up-to-date"
fi