Created
February 3, 2022 07:42
-
-
Save pawel-t/e0ad8801875dc3fdecc6859126caefee to your computer and use it in GitHub Desktop.
Use ansible to download latest github release assets
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
- name: Get assets | |
get_url: | |
url: "https://api.github.com/repos/{{ username }}/{{ repo_name }}/releases/latest?access_token={{ github_token }}" | |
force: yes | |
headers: | |
Accept: "application/vnd.github.v3+json" | |
dest: "/tmp/{{ assets_response }}" | |
- name: Get download url | |
shell: | | |
cat "/tmp/{{ assets_response }}" | jq '.assets | .[] | select(.browser_download_url | contains("_Linux_amd64.tar.gz")) | .url' | sed -e 's/^"//' -e 's/"$//' | |
register: "download_url" | |
- debug: | |
msg: "{{ download_url.stdout }}" | |
- name: Download latest release | |
get_url: | |
url: "{{ download_url.stdout }}?access_token={{ github_token }}" | |
dest: /tmp/latest_asset.tar.xz | |
tmp_dest: /tmp/ | |
force: yes | |
headers: | |
Accept: "application/octet-stream" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment