Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script and GitHub action to automatically update templated packages. #335

Merged
merged 3 commits into from
Mar 5, 2021

Conversation

p37ruh4
Copy link
Contributor

@p37ruh4 p37ruh4 commented Feb 15, 2021

Add script and GitHub action to automatically update package versions to latest releases in templating.yaml file.
Sample output of the script:

$ python3 update_templating_versions.py 
INFO:root:Checking updates for NODE EXPORTER
INFO:root:Latest node_exporter release version: 1.1.1
INFO:root:node_exporter: current version: 1.1.0, latest version 1.1.1
INFO:root:Branch 'node_exporter_1_1_1' is already present, not pushing updates
INFO:root:Checking updates for MYSQLD EXPORTER
INFO:root:Latest mysqld_exporter release version: 0.12.1
INFO:root:mysqld_exporter: current version: 0.12.1, latest version 0.12.1
INFO:root:Checking updates for REDIS EXPORTER
INFO:root:Latest redis_exporter release version: 1.17.0
INFO:root:redis_exporter: current version: 1.16.0, latest version 1.17.0
INFO:root:Branch 'redis_exporter_1_17_0' is already present, not pushing updates
INFO:root:Checking updates for HAPROXY EXPORTER
INFO:root:Latest haproxy_exporter release version: 0.12.0
INFO:root:haproxy_exporter: current version: 0.12.0, latest version 0.12.0
INFO:root:Checking updates for KAFKA EXPORTER
INFO:root:Latest kafka_exporter release version: 1.2.0
INFO:root:kafka_exporter: current version: 1.2.0, latest version 1.2.0
INFO:root:Checking updates for NGINX EXPORTER
INFO:root:Latest nginx_exporter release version: 0.8.0
INFO:root:nginx_exporter: current version: 0.8.0, latest version 0.8.0
INFO:root:Checking updates for BIND EXPORTER
INFO:root:Latest bind_exporter release version: 0.4.0
INFO:root:bind_exporter: current version: 0.4.0, latest version 0.4.0
INFO:root:Checking updates for KEEPALIVED EXPORTER
INFO:root:Latest keepalived_exporter release version: 0.5.0
INFO:root:keepalived_exporter: current version: 0.5.0, latest version 0.5.0
INFO:root:Checking updates for JOLOKIA EXPORTER
INFO:root:Latest jolokia_exporter release version: 1.3.1
INFO:root:jolokia_exporter: current version: 1.3.1, latest version 1.3.1
INFO:root:Checking updates for PUSHGATEWAY
INFO:root:Latest pushgateway release version: 1.4.0
INFO:root:pushgateway: current version: 1.4.0, latest version 1.4.0
INFO:root:Checking updates for FRR EXPORTER
INFO:root:Latest frr_exporter release version: 0.2.12
INFO:root:frr_exporter: current version: 0.2.11, latest version 0.2.12
INFO:root:Updating frr_exporter: 0.2.11 -> 0.2.12
INFO:root:Pull request #3 created

Workflow is configured to run twice per day.

@p37ruh4
Copy link
Contributor Author

p37ruh4 commented Feb 15, 2021

@lest, you will need to create new GitHub token with access to public_repo scope:
Screenshot 2021-02-14 at 18 16 53

When token is created, you will need to add GH_TOKEN secret in this repository with value of that token.

@karlism karlism mentioned this pull request Feb 15, 2021
@lest
Copy link
Owner

lest commented Feb 15, 2021

I like the idea of automatically checking for new versions and creating pull requests. I'll create a separate GitHub bot account to use its personal token instead of mine.

@lest
Copy link
Owner

lest commented Feb 15, 2021

@p37ruh4 Is it possible to use a token from a separate GitHub bot account or is it required to use my personal token? I'm not sure if the script supports it being a token from a separate account so it can open pull requests from prometheus-rpm-bot/prometheus-rpm@branch to lest/prometheus-rpm@master.

@p37ruh4
Copy link
Contributor Author

p37ruh4 commented Feb 15, 2021

It should be possible to use any account, it might be required to add that bot account some additional permissions on lest/prometheus-rpm repository, but I'm not sure.
Tokens are used in 2 different ways in this script:

  1. to request release information for different exporters, it is recommended to authenticate requests with token as authenticated requests have bigger quotas regarding API requests compared to anonymous ones;
  2. to create PR in this repo

@p37ruh4
Copy link
Contributor Author

p37ruh4 commented Feb 17, 2021

@p37ruh4 Is it possible to use a token from a separate GitHub bot account or is it required to use my personal token? I'm not sure if the script supports it being a token from a separate account so it can open pull requests from prometheus-rpm-bot/prometheus-rpm@branch to lest/prometheus-rpm@master.

@lest, have you had any success creating bot account and token?

@lest
Copy link
Owner

lest commented Feb 19, 2021

@p37ruh4 Is it possible to use a token from a separate GitHub bot account or is it required to use my personal token? I'm not sure if the script supports it being a token from a separate account so it can open pull requests from prometheus-rpm-bot/prometheus-rpm@branch to lest/prometheus-rpm@master.

@lest, have you had any success creating bot account and token?

I created a bot account and added its token to secrets. However, I haven't tested how it works yet. I'll try to do as soon as possible.

@britcey
Copy link
Collaborator

britcey commented Feb 26, 2021

Any update on this? We've got a few of the major packages (prometheus, node_exporter) that are awaiting updates.

@karlism
Copy link
Collaborator

karlism commented Mar 5, 2021

I will merge this as this cannot break anything and worst case scenario is we will have workflow that doesn't work and can be disabled by adjusting crontab.

@karlism karlism merged commit d616923 into lest:master Mar 5, 2021
@karlism
Copy link
Collaborator

karlism commented Mar 5, 2021

I'll try to figure it out tomorrow on forked repository, it appears to be creating PRs in wrong repo: https://github.com/karlism/prometheus-rpm/pull/1

@karlism
Copy link
Collaborator

karlism commented Mar 6, 2021

I think I've fixed the script, but now action fails as bot account does not have permissions to create new branches in this repository.
@lest, can you please invite bot account as collaborator to this repo?

@lest
Copy link
Owner

lest commented Mar 8, 2021

@karlism done! sorry for the late response and thanks a lot for improving the script.

@karlism
Copy link
Collaborator

karlism commented Mar 8, 2021

@lest, thanks, appears to be working properly now: https://github.com/lest/prometheus-rpm/actions/runs/632452522 created #341

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants