Skip to content

Commit

Permalink
Add support for adding secrets in coherent projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Aug 25, 2024
1 parent e0645f7 commit 10ffe04
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
15 changes: 13 additions & 2 deletions jaraco/develop/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import keyring
import nacl.encoding
import nacl.public
from jaraco.functools import apply
from more_itertools import unique_everseen
from requests_toolbelt import sessions

from . import repo
Expand Down Expand Up @@ -76,14 +78,23 @@ def create_release(self, tag):
return resp

@classmethod
@apply(unique_everseen)
def find_needed_secrets(cls):
"""
>>> list(Repo.find_needed_secrets())
['PYPI_TOKEN']
"""
workflows = pathlib.Path('.github/workflows').iterdir()
all = itertools.chain.from_iterable(map(cls.find_secrets, workflows))
return itertools.filterfalse('GITHUB_TOKEN'.__eq__, all)
found = itertools.chain.from_iterable(map(cls.find_secrets, workflows))
inferred = itertools.chain.from_iterable(map(cls.infer_secrets, workflows))
needed = itertools.chain(found, inferred)
return itertools.filterfalse('GITHUB_TOKEN'.__eq__, needed)

@staticmethod
def infer_secrets(file):
return ['PYPI_TOKEN'] * 'uses: coherent-oss/system' in file.read_text(
encoding='utf-8'
)

@staticmethod
def find_secrets(file):
Expand Down
1 change: 1 addition & 0 deletions newsfragments/+cb86fac7.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for adding secrets in coherent projects.

0 comments on commit 10ffe04

Please sign in to comment.