mirror of
https://github.com/prometheus-community/ansible
synced 2024-11-22 20:03:04 +00:00
ci: gitlab.com support for version updater
Signed-off-by: anviar <oleg.kluchkin+github@gmail.com>
This commit is contained in:
parent
b780522780
commit
45595a7d65
5 changed files with 15 additions and 5 deletions
2
.github/scripts/discover_role_repos.sh
vendored
2
.github/scripts/discover_role_repos.sh
vendored
|
@ -5,7 +5,7 @@
|
|||
result=$(
|
||||
for defaults_file in roles/*/vars/main.yml ; do
|
||||
role="$(echo "${defaults_file}" | cut -f2 -d'/')"
|
||||
yq eval "[{\"repo\": ._${role}_repo, \"role\": \"${role}\"}]" "${defaults_file}"
|
||||
yq eval "[{\"repo\": ._${role}_repo, \"role\": \"${role}\", \"type\": ._${role}_repo_type // \"github\"}]" "${defaults_file}"
|
||||
done | yq -o json -I=0
|
||||
)
|
||||
|
||||
|
|
11
.github/scripts/version_updater.sh
vendored
11
.github/scripts/version_updater.sh
vendored
|
@ -13,6 +13,7 @@ fi
|
|||
|
||||
source_repo="$1"
|
||||
role="$2"
|
||||
type="$3"
|
||||
|
||||
color_red='\e[31m'
|
||||
color_green='\e[32m'
|
||||
|
@ -67,7 +68,15 @@ if [[ -z "${role}" ]]; then
|
|||
fi
|
||||
|
||||
# Get latest version.
|
||||
version="$(github_api "repos/${source_repo}/releases/latest" | jq '.tag_name' | tr -d '"v')"
|
||||
if [[ ${type} == "github" ]]
|
||||
then
|
||||
version="$(github_api "repos/${source_repo}/releases/latest" | jq '.tag_name' | tr -d '"v')"
|
||||
elif [[ ${type} == "gitlab" ]]
|
||||
version="$(curl https://gitlab.com/api/v4/projects/${source_repo}/releases|jq '.[0].tag_name'| tr -d '"v')"
|
||||
else
|
||||
echo_red 'Unknown source type. Terminating.'
|
||||
exit 128
|
||||
fi
|
||||
echo_green "New ${source_repo} version is: ${version}"
|
||||
|
||||
# Download destination repository
|
||||
|
|
2
.github/workflows/version_bumper.yml
vendored
2
.github/workflows/version_bumper.yml
vendored
|
@ -37,4 +37,4 @@ jobs:
|
|||
include: ${{ fromJson(needs.discover-role-repos.outputs.role-repos) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- run: ./.github/scripts/version_updater.sh ${{ matrix.repo }} ${{ matrix.role }}
|
||||
- run: ./.github/scripts/version_updater.sh ${{ matrix.repo }} ${{ matrix.role }} ${{ matrix.type }}
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
- name: Discover latest version
|
||||
ansible.builtin.set_fact:
|
||||
fail2ban_exporter_version: "{{ (lookup('url', 'https://gitlab.com/api/v4/projects/{{ _gitlab_projectid }}/releases',
|
||||
fail2ban_exporter_version: "{{ (lookup('url', 'https://gitlab.com/api/v4/projects/{{ _fail2ban_exporter_repo }}/releases',
|
||||
split_lines=False) | from_json)[0].get('tag_name') | replace('v', '') }}"
|
||||
run_once: true
|
||||
until: fail2ban_exporter_version is version('0.0.0', '>=')
|
||||
|
|
|
@ -7,4 +7,5 @@ go_arch_map:
|
|||
armv6l: 'armv6'
|
||||
|
||||
go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
|
||||
_gitlab_projectid: 24199687
|
||||
_fail2ban_exporter_repo: 24199687
|
||||
_fail2ban_exporter_repo_type: gitlab
|
||||
|
|
Loading…
Reference in a new issue