-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[noissue]
- Loading branch information
Showing
11 changed files
with
157 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2021.08.26-219-g66afab8 | ||
2021.08.26-233-gd6a6b5f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# WARNING: DO NOT EDIT! | ||
# | ||
# This file was generated by plugin_template, and is managed by it. Please use | ||
# './plugin-template --github pulp_certguard' to update this file. | ||
# | ||
# For more info visit https://github.com/pulp/plugin_template | ||
|
||
import requests | ||
import yaml | ||
import random | ||
import os | ||
|
||
|
||
def random_color(): | ||
"""Generates a random 24-bit number in hex""" | ||
color = random.randrange(0, 2**24) | ||
return format(color, "06x") | ||
|
||
|
||
session = requests.Session() | ||
token = os.getenv("GITHUB_TOKEN") | ||
|
||
headers = { | ||
"Authorization": f"token {token}", | ||
"Accept": "application/vnd.github+json", | ||
"X-GitHub-Api-Version": "2022-11-28", | ||
} | ||
session.headers.update(headers) | ||
|
||
# get all labels from the repository's current state | ||
response = session.get("https://api.github.com/repos/pulp/pulp_certguard/labels", headers=headers) | ||
assert response.status_code == 200 | ||
old_labels = set([x["name"] for x in response.json() if x["name"].startswith("backport-")]) | ||
|
||
# get ci_update_branches from template_config.yml | ||
with open("./template_config.yml", "r") as f: | ||
plugin_template = yaml.safe_load(f) | ||
new_labels = set(["backport-" + x for x in plugin_template["ci_update_branches"]]) | ||
|
||
# delete old labels that are not in new labels | ||
for label in old_labels.difference(new_labels): | ||
response = session.delete( | ||
f"https://api.github.com/repos/pulp/pulp_certguard/labels/{label}", headers=headers | ||
) | ||
assert response.status_code == 204 | ||
|
||
# create new labels that are not in old labels | ||
for label in new_labels.difference(old_labels): | ||
color = random_color() | ||
response = session.post( | ||
"https://api.github.com/repos/pulp/pulp_certguard/labels", | ||
headers=headers, | ||
json={"name": label, "color": color}, | ||
) | ||
assert response.status_code == 201 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# WARNING: DO NOT EDIT! | ||
# | ||
# This file was generated by plugin_template, and is managed by it. Please use | ||
# './plugin-template --github pulp_certguard' to update this file. | ||
# | ||
# For more info visit https://github.com/pulp/plugin_template | ||
|
||
|
||
--- | ||
name: Certguard Update Labels | ||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'template_config.yml' | ||
|
||
jobs: | ||
update_backport_labels: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.8" | ||
- name: Configure Git with pulpbot name and email | ||
run: | | ||
git config --global user.name 'pulpbot' | ||
git config --global user.email 'pulp-infra@redhat.com' | ||
- name: Install python dependencies | ||
run: | | ||
echo ::group::PYDEPS | ||
pip install requests pyyaml | ||
echo ::endgroup:: | ||
- uses: actions/checkout@v3 | ||
- name: Update labels | ||
run: | | ||
python3 .github/workflows/scripts/update_backport_labels.py | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters