Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Send automated PR upon new stack release
- Loading branch information
Showing
1 changed file
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Update Elastic release | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 * * 0' # At 00:00 every Sunday | ||
|
||
jobs: | ||
|
||
check-and-update: | ||
name: Check and update Elastic release | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Get latest release version | ||
uses: octokit/request-action@v2.x | ||
id: get_latest_release | ||
with: | ||
route: GET /repos/:repository/releases/latest | ||
repository: elastic/elasticsearch | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update stack version | ||
run: | | ||
source .env | ||
cur_ver="$ELK_VERSION" | ||
new_ver=${{ fromJson(steps.get_latest_release.outputs.data).tag_name }} | ||
# Escape dot characters so sed interprets them as literal dots | ||
cur_ver="$(echo $cur_ver | sed 's/\./\\./g')" | ||
# Trim leading 'v' in semantic version | ||
new_ver="${new_ver:1}" | ||
for f in .env docker-stack.yml README.md; do | ||
sed -i "s/${cur_ver}/${new_ver}/g" "$f" | ||
done | ||
- name: Send pull request to update to new version | ||
uses: peter-evans/create-pull-request@v3 | ||
with: | ||
commit-message: Update to ${{ fromJson(steps.get_latest_release.outputs.data).tag_name }} | ||
title: Update to ${{ fromJson(steps.get_latest_release.outputs.data).tag_name }} | ||
delete-branch: true |