If the `GITHUB_TOKEN` is defined in the Ansible controller's environment it is used to set the GitHub REST API authentication header. This is they passed to all `uri` modules tasks which interact with the GitHub REST API. If the `GITHUB_TOKEN` is not set, the authentication header is not used. Fixes #19
58 lines
1.6 KiB
YAML
58 lines
1.6 KiB
YAML
---
|
|
- name: stat version file
|
|
stat:
|
|
path: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
|
register: version_file
|
|
|
|
- name: slurp version
|
|
when: version_file.stat.exists
|
|
slurp:
|
|
path: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
|
register: version_slurp
|
|
|
|
- when: version_file.stat.exists
|
|
set_fact:
|
|
version: '{{version_slurp.content | b64decode}}'
|
|
|
|
- name: get latest release
|
|
uri:
|
|
url: https://api.github.com/repos/ryanoasis/nerd-fonts/releases/latest
|
|
headers: '{{github_auth_headers}}'
|
|
register: latest
|
|
|
|
- set_fact:
|
|
needs_installed:
|
|
'{{ not version_file.stat.exists or version.strip() != latest.json.tag_name }}'
|
|
asset: '{{ latest.json.assets | to_json | from_json |
|
|
json_query("[?contains(name, `CascadiaCode.zip`)] | [0]") }}'
|
|
|
|
- name: create user fonts directory
|
|
when: needs_installed
|
|
file:
|
|
path: '{{ansible_env.HOME}}/.local/share/fonts'
|
|
state: directory
|
|
|
|
- name: download Caskaydia Cove Nerd Font archive
|
|
when: needs_installed
|
|
get_url:
|
|
url: '{{asset.browser_download_url}}'
|
|
dest: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
|
|
|
- name: install Caskaydia Cove Nerd Font
|
|
when: needs_installed
|
|
unarchive:
|
|
src: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
|
dest: '{{ansible_env.HOME}}/.local/share/fonts'
|
|
notify: refresh font cache
|
|
|
|
- name: write version file
|
|
copy:
|
|
content: '{{latest.json.tag_name}}'
|
|
dest: '{{ansible_env.HOME}}/.local/share/fonts/CaskaydiaCove.version'
|
|
|
|
- name: remove Caskaydia Cove Nerd Font archive
|
|
when: needs_installed
|
|
file:
|
|
path: '{{ansible_env.HOME}}/.local/share/fonts/tmp.zip'
|
|
state: absent
|