{"id":15971709,"url":"https://github.com/vkuznet/imagebot","last_synced_at":"2025-04-04T15:45:08.093Z","repository":{"id":136818108,"uuid":"322120890","full_name":"vkuznet/imagebot","owner":"vkuznet","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-10T12:50:02.000Z","size":40,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-10T01:41:27.588Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vkuznet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-12-16T22:50:09.000Z","updated_at":"2023-03-08T12:46:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"1890cf56-d6e8-4b95-92d1-a0f169a550fc","html_url":"https://github.com/vkuznet/imagebot","commit_stats":null,"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkuznet%2Fimagebot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkuznet%2Fimagebot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkuznet%2Fimagebot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vkuznet%2Fimagebot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vkuznet","download_url":"https://codeload.github.com/vkuznet/imagebot/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247208066,"owners_count":20901568,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-07T20:40:25.595Z","updated_at":"2025-04-04T15:45:08.059Z","avatar_url":"https://github.com/vkuznet.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"### imagebot\n\n[![GitHubActions Status](https://github.com/vkuznet/imagebot/workflows/Build/badge.svg)](https://github.com/vkuznet/imagebot/actions)\n[![Go Report Card](https://goreportcard.com/badge/github.com/vkuznet/imagebot)](https://goreportcard.com/report/github.com/vkuznet/imagebot)\n\nThe imagebot service is designed to update k8s services via CD/CI pipeline.\nThe CD/CI pipeline may be based on GitHub Action where one of the action will\ncall this service to request update of the image on k8s infrastructure.\n\nTo do that we need few pieces:\n- add secrets into your GitHub repository\n- setup service on your k8s infrastructure\n- configure imagebot with allowed set of namespaces, repositories and services\n\n#### Required secrets\nIn order to enabled CD/CI pipeline for your github repository and allow\nimagebot to update images on k8s infrastructure\nplease create appropriate GitHub secrets in your github repository:\n- `IMAGEBOT_URL` represents URL of imagebot service\n- `SERVICE_NAMESPACE` refers to application namespace\n- `DOCKER_IMAGE` referts to docker hub image name\n\nPlease note: your namespace should be part of imagebot configuration\n\n#### imagebot configuration\nThe configuration of the service should include\n```\n# secret represents imagebot secret used for token creation/encryption\n# tokenInterval setups validity interval in seconds for generated token\n# namespaces lists allowed namespaces\n# services lists allowed services\n# repository lists allowed repositories\n# please note: namespaces/services/repositories list represent triplets\n{\n    \"port\": 8111,\n    \"base\": \"\",\n    \"namespaces\": [\"ns1\", \"ns2\"],\n    \"services\": [\"srv1\", \"srv2\"],\n    \"images\": [\"repo1/srv1\", \"repo2/srv2\"],\n    \"secret\": \"bla-bla-bla\",\n    \"tokenInverval\": 600,\n    \"verbose\": 1\n}\n```\nFor the full set of allowed parameters please see `server.go` code.\n\n### Testing procedure\nTo test the service please run it as following:\n```\nimagebot -config config.json\n```\nand place two requests:\n```\n# first request to obtain the token\ncurl -v -X POST -H \"content-type: application/json\" \\\n    -d '{\"commit\":\"dad51084ea82ab2f6f573b6daa464ed0d7c23a1d\", \"namespace\": \"http\", \\\n         \"repository\": \"vkuznet/httpgo\", \"tag\":\"00.00.01\", \"image\": \"httpgo:123\", \\\n         \"service\":\"httpgo\"}' http://localhost:8111/token\n\n\n# second request to process workflow\ncurl -v -X POST -H \"Authorization: Bearer $token\" -H \"content-type: application/json\" \\\n    -d '{\"commit\":\"dad51084ea82ab2f6f573b6daa464ed0d7c23a1d\", \"namespace\": \"http\", \\\n         \"repository\": \"vkuznet/httpgo\", \"tag\":\"00.00.01\", \"image\": \"httpgo:123\", \\\n         \"service\":\"httpgo\"}' http://localhost:8111\n```\n\n### repository settings\nGitHub package should have the following workflow steps:\n```\n# some workflow organization\nname: Create issue on commit\non:\n- push\njobs:\n  create_commit:\n    runs-on: ubuntu-latest\n    steps:\n    #\n    ####### ADD THIS STEP to your GitHubAction workflow\n    # and replace NAMESPACE, SERVICE, IMAGE with appropriate values\n    - name: Push new image to k8s\n      run: |\n        curl -ksLO https://raw.githubusercontent.com/vkuznet/imagebot/main/imagebot.sh\n        sed -i -e \"s,COMMIT,${{github.sha}},g\" -e \"s,REPOSITORY,${{github.repository}},g\" -e \"s,NAMESPACE,http,g\" -e \"s,TAG,${{steps.get-ref.outputs.tag}},g\" -e \"s,IMAGE,cmssw/httpgo,g\" -e \"s,SERVICE,httpgo,g\" -e \"s,HOST,${{secrets.IMAGEBOT_URL}},g\" imagebot.sh\n        chmod +x imagebot.sh\n        sh ./imagebot.sh\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkuznet%2Fimagebot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvkuznet%2Fimagebot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvkuznet%2Fimagebot/lists"}