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 Argument to Specify YAML File Path #813

Merged
merged 6 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ inputs:
description: 'Version schema of rock repository'
required: false
default: 'None'
yaml-path:
description: 'Path to the YAML file'
required: false
default: 'snapcraft.yaml'

# Outputs generated by running this action.
outputs:
Expand Down Expand Up @@ -49,7 +53,7 @@ runs:
- name: run updatesnapyaml
id: updatesnapyaml
run: |
./desktop-snaps/updatesnap/updatesnapyaml.py --github-user $GITHUB_USER --github-token $GITHUB_TOKEN --version-schema $VERSION_SCHEMA --rock-version-schema $ROCK_VERSION_SCHEMA https://github.com/${{ github.repository }}
./desktop-snaps/updatesnap/updatesnapyaml.py --github-user $GITHUB_USER --github-token $GITHUB_TOKEN --version-schema $VERSION_SCHEMA --rock-version-schema $ROCK_VERSION_SCHEMA --yaml-path $YAML_PATH https://github.com/${{ github.repository }}
# Make sure to put the updated snapcraft.yaml file in the right location if it lives in a snap directory
if [ -f version_file ]; then
echo "IS_VERSION_CHANGE=true" >> $GITHUB_ENV
Expand All @@ -70,6 +74,7 @@ runs:
GITHUB_TOKEN: ${{ inputs.token }}
VERSION_SCHEMA: ${{ inputs.version-schema }}
ROCK_VERSION_SCHEMA: ${{ inputs.rock-version-schema }}
YAML_PATH: ${{ inputs.yaml-path }}
shell: bash

# Step to remove the desktop-snaps folder so that when we commit changes in another repo, the desktop-snaps folder is not committed there.
Expand Down
13 changes: 4 additions & 9 deletions updatesnap/updatesnapyaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ def get_working_branch(self, project_url):
break
return working_branch

def get_yaml_file(self, project_url):
def get_yaml_file(self, project_url, yaml_path):
""" Searches in a project for the 'snapcraft.yaml' file and
rudra-iitm marked this conversation as resolved.
Show resolved Hide resolved
returns its contents """
yaml_path = 'snapcraft.yaml'
try:
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
Expand All @@ -54,12 +53,6 @@ def get_yaml_file(self, project_url):
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
data = None
if not data:
rudra-iitm marked this conversation as resolved.
Show resolved Hide resolved
yaml_path = 'rockcraft.yaml'
try:
data = self._github.get_file(project_url, yaml_path)
except (ValueError, ConnectionError):
data = None
return data


Expand All @@ -76,6 +69,8 @@ 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',
help='Path to the yaml file')
parser.add_argument('--verbose', action='store_true', default=False)
parser.add_argument('project', default='.', help='The project URI')
arguments = parser.parse_args(sys.argv[1:])
Expand All @@ -88,7 +83,7 @@ def main():

# get the most-updated SNAPCRAFT.YAML file

data = manager.get_yaml_file(arguments.project)
data = manager.get_yaml_file(arguments.project, arguments.yaml_path)
if not data:
print('Failed to get the snapcraft.yaml file.', file=sys.stderr)
sys.exit(-1)
Expand Down