1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_forgeo_runner.git synced 2024-08-16 10:29:50 +02:00
ansible_role_forgeo_runner/tasks/set_runner_version.yml

46 lines
2 KiB
YAML

---
- name: "Check forgejo runner installed version"
ansible.builtin.shell: "set -eo pipefail; {{ forgejo_runner__full_executable_path }} --version | cut -d' ' -f 3"
args:
executable: /bin/bash
register: forgejo_runner__active_version
changed_when: false
failed_when: false
- name: "Determine 'latest' forgejo runner version release"
when: forgejo_runner__version == "latest"
block:
- name: "Get latest forgejo runner release metadata"
ansible.builtin.uri:
url: "{{ forgejo_runner__releases_latest }}"
return_content: true
register: forgejo_runner__remote_metadata
become: false
when: not ansible_check_mode
- name: "Fail if running in check mode without versions set."
ansible.builtin.fail:
msg: |
"You are running this playbook in check mode:
Please set the forgejo runner version with the variable 'forgejo_runner__version', because the URI module cannot detect the latest version in this mode."
when: ansible_check_mode and (forgejo_runner__version == 'latest')
- name: "Set fact latest forgejo runner release"
ansible.builtin.set_fact:
forgejo_runner__remote_version: "{{ forgejo_runner__remote_metadata.json.0.tag_name[1:] }}"
when: not ansible_check_mode
- name: "Set forgejo runner version target (latest)"
ansible.builtin.set_fact:
forgejo_runner__version_target: "{{ forgejo_runner__remote_version }}"
when: not ansible_check_mode
- name: "Set forgejo runner version target {{ forgejo_runner__version }}"
ansible.builtin.set_fact:
forgejo_runner__version_target: "{{ forgejo_runner__version }}"
when: forgejo_runner__version != "latest"
- name: "Generate forgejo runner download URL"
ansible.builtin.set_fact:
forgejo_runner__filename: "forgejo-runner-{{ forgejo_runner__version_target }}-linux-{{ forgejo_runner__arch }}"
forgejo_runner__dl_url: "{{ forgejo_runner__git_repo }}/releases/download/v{{ forgejo_runner__version_target }}"