diff --git a/action.yml b/action.yml index d25b8bd..a7d7147 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ inputs: yaml-path: description: 'Path to the YAML file' required: false - default: 'snapcraft.yaml' + default: 'None' # Outputs generated by running this action. outputs: diff --git a/updatesnap/updatesnapyaml.py b/updatesnap/updatesnapyaml.py index c397bde..6ccde7c 100755 --- a/updatesnap/updatesnapyaml.py +++ b/updatesnap/updatesnapyaml.py @@ -43,6 +43,14 @@ def get_working_branch(self, project_url): def get_yaml_file(self, project_url, yaml_path): """ Searches in a project for the 'snapcraft.yaml' file and returns its contents """ + if yaml_path != 'None': + try: + data = self._github.get_file(project_url, yaml_path) + except (ValueError, ConnectionError): + data = None + return data + + yaml_path = 'snapcraft.yaml' try: data = self._github.get_file(project_url, yaml_path) except (ValueError, ConnectionError): @@ -53,6 +61,12 @@ def get_yaml_file(self, project_url, yaml_path): data = self._github.get_file(project_url, yaml_path) except (ValueError, ConnectionError): data = None + if not data: + yaml_path = 'rockcraft.yaml' + try: + data = self._github.get_file(project_url, yaml_path) + except (ValueError, ConnectionError): + data = None return data @@ -69,7 +83,7 @@ def main(): help='Version schema of snapping repository') parser.add_argument('--rock-version-schema', action='store', default='None', help='Version schema of rock repository') - parser.add_argument('--yaml-path', action='store', default='snapcraft.yaml', + parser.add_argument('--yaml-path', action='store', default='None', help='Path to the yaml file') parser.add_argument('--verbose', action='store_true', default=False) parser.add_argument('project', default='.', help='The project URI')