first commit
This commit is contained in:
148
system/upgrade_github_application.yaml
Normal file
148
system/upgrade_github_application.yaml
Normal file
@@ -0,0 +1,148 @@
|
||||
# yaml-language-server: $schema=https://git.jesof.ch/public/mstr-schemas/raw/branch/main/mstr-tasks-schema.json
|
||||
tasks:
|
||||
- execute:
|
||||
description: "Get URL for latest version"
|
||||
exec: "curl"
|
||||
hideStdout: true
|
||||
args:
|
||||
- "-s"
|
||||
- "$(settings.api_url)"
|
||||
parsers:
|
||||
- name: "Get Download URL"
|
||||
parser: "jq"
|
||||
expression: '.assets[] | select(.name | test("$(settings.search)")) | .browser_download_url'
|
||||
variables:
|
||||
- download_url
|
||||
- name: "Get Tag Name"
|
||||
parser: "jq"
|
||||
expression: ".tag_name"
|
||||
variables:
|
||||
- tag_name
|
||||
|
||||
- set:
|
||||
description: "Set variables"
|
||||
variables:
|
||||
- varName: "new_version"
|
||||
value: '$(trimPrefix(tag_name,"v"))'
|
||||
- varName: "archive_file"
|
||||
value: '$(settings.name)_$(trimPrefix(tag_name,"v"))_$(settings.os_family)-$(settings.architecture).tar.gz'
|
||||
- varName: "sha256_file"
|
||||
value: '$(settings.name)_$(trimPrefix(tag_name,"v"))_$(settings.os_family)-$(settings.architecture).sha256'
|
||||
|
||||
- loadVariables:
|
||||
description: "Load variables for $(settings.name)"
|
||||
url: "@(provisioning)/roles/$(settings.name)/vars/version.yaml"
|
||||
|
||||
- return:
|
||||
description: "Latest version installed $(new_version)"
|
||||
when: $(new_version == app_version)
|
||||
|
||||
- execute:
|
||||
description: "Download application from $(download_url)"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "-L"
|
||||
- "--silent"
|
||||
- "-o"
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "$(download_url)"
|
||||
|
||||
- execute:
|
||||
exec: "mv"
|
||||
args:
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "$(tempdir())/$(settings.bin_file)"
|
||||
when: '$(settings.bin_file != "")'
|
||||
|
||||
- tar:
|
||||
source: "$(tempdir())/$(settings.bin_file)"
|
||||
archiveFile: "$(tempdir())/$(archive_file)"
|
||||
when: '$(settings.bin_file != "")'
|
||||
|
||||
- sha256:
|
||||
description: "Calculate checksum"
|
||||
file: "$(tempdir())/$(archive_file)"
|
||||
varName: "checkSum"
|
||||
|
||||
- write:
|
||||
description: "Save checksum file $(sha256_file) "
|
||||
file: "$(tempdir())/$(sha256_file)"
|
||||
format: "%s"
|
||||
args:
|
||||
- "$(checkSum)"
|
||||
|
||||
- execute:
|
||||
description: "Upload application $(archive_file)"
|
||||
exec: "mc"
|
||||
args:
|
||||
- "cp"
|
||||
- "--quiet"
|
||||
- "$(tempdir())/$(archive_file)"
|
||||
- "jesof/binaries/$(archive_file)"
|
||||
|
||||
- execute:
|
||||
description: "Upload checksum $(sha256_file)"
|
||||
exec: "mc"
|
||||
args:
|
||||
- "cp"
|
||||
- "--quiet"
|
||||
- "$(tempdir())/$(sha256_file)"
|
||||
- "jesof/binaries/$(sha256_file)"
|
||||
|
||||
- call:
|
||||
script: "@(system)/check-git-repository.yaml"
|
||||
args:
|
||||
path: "@(provisioning)"
|
||||
returns:
|
||||
- gitChanges
|
||||
|
||||
- throw:
|
||||
description: "Check if repository is clean"
|
||||
message: 'Git repository "@(provisioning)" not clean, please commit changes ...'
|
||||
when: $(gitChanges != "")
|
||||
|
||||
- template:
|
||||
templates:
|
||||
- "@(system)/upgrade_applications_version.yaml"
|
||||
target: "@(provisioning)/roles/$(settings.name)/vars/version.yaml"
|
||||
args:
|
||||
version: "$(new_version)"
|
||||
|
||||
- execute:
|
||||
description: "Deploy $(settings.name)"
|
||||
exec: "orchestra"
|
||||
dir: "@(provisioning)"
|
||||
args:
|
||||
- "-roles"
|
||||
- "$(settings.name)"
|
||||
|
||||
- execute:
|
||||
description: "Check health endpoint"
|
||||
exec: "curl"
|
||||
args:
|
||||
- "--retry"
|
||||
- "10"
|
||||
- "--silent"
|
||||
- $(settings.health_url)
|
||||
when: $(has("settings.health_url"))
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "add"
|
||||
- "."
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "commit"
|
||||
- "-m"
|
||||
- "New $(settings.name) release"
|
||||
|
||||
- execute:
|
||||
dir: "@(provisioning)"
|
||||
exec: "git"
|
||||
args:
|
||||
- "push"
|
||||
Reference in New Issue
Block a user