-
Notifications
You must be signed in to change notification settings - Fork 16
40 lines (38 loc) · 1.49 KB
/
consul-version.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
name: Update Consul Version
on:
schedule:
- cron: "0 8 * * *"
jobs:
update_consul_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
persist-credentials: false
fetch-depth: 0
- name: Update Consul Version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd ./packer/scripts
CURRENT=$(cat install_consul.sh | grep "CONSUL_VERSION=" | awk -F '=' '{print $2}')
LATEST=$(curl --silent https://releases.hashicorp.com/index.json | jq -r '.consul.versions | keys | .[]' | grep -v "-" | grep -v "+" | sort --version-sort | tail -n 1)
if [ "$CURRENT" != "$LATEST" ]; then
echo "Consul version $CURRENT is out-of-date, updating to $LATEST"
# configure git
git config user.name "Consul 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_consul.sh
# update README
cd -
sed -i "s/$CURRENT/$LATEST/g" README.md
# rest of git workflow
git add .
git commit -m "consul-update-bot: update version from $CURRENT to $LATEST" || exit 1
git status
git push origin HEAD:master
else
echo "consul version $CURRENT is already up-to-date"
fi