diff --git a/.github/workflows/build-tools-docker.yml b/.github/workflows/build-tools-docker.yml deleted file mode 100644 index 735c26c99..000000000 --- a/.github/workflows/build-tools-docker.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Build Docker images - -on: - push: - branches: - - '**' - tags: - - 'v*' - paths: - - 'scripts/gen-index-yml/**' - -env: - REGISTRY: ghcr.io - -permissions: - contents: read - packages: write - -jobs: - docker: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Docker meta - id: meta - uses: docker/metadata-action@v4 - with: - images: ${{ env.REGISTRY }}/alfresco/build-tools-gen-index-yml - tags: | - type=ref,event=branch - type=semver,pattern={{version}} - type=semver,pattern={{major}}.{{minor}} - - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Log in to the Container registry - uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 - with: - registry: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v4 - with: - context: ./scripts/gen-index-yml - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} diff --git a/scripts/gen-index-yml/Dockerfile b/scripts/gen-index-yml/Dockerfile deleted file mode 100644 index c3ec4ccde..000000000 --- a/scripts/gen-index-yml/Dockerfile +++ /dev/null @@ -1,9 +0,0 @@ -FROM python:alpine3.18 - -WORKDIR /root -ADD requirements.txt . -RUN pip install -r requirements.txt - -ADD gen_index_yml.py /usr/bin/ - -ENTRYPOINT ["python", "/usr/bin/gen_index_yml.py"] diff --git a/scripts/gen-index-yml/README.md b/scripts/gen-index-yml/README.md deleted file mode 100644 index cdc83942f..000000000 --- a/scripts/gen-index-yml/README.md +++ /dev/null @@ -1,18 +0,0 @@ -# Generate a yaml index from subfolders in a folder - -This is a quick script which can enumerate subfolders inside a given folder and -generate/update a yaml which contains a dictionary where each entry is a subfolder name. - -Can be used in GitHub Actions matrix workflows to generate the list to iterate. - -Can be hooked in pre-commit as a local hook with: - -```yaml - - repo: local - hooks: - - id: update-index-yml - name: update charts.yml file - language: docker_image - entry: ghcr.io/alfresco/build-tools-gen-index-yml:master - pass_filenames: false -``` diff --git a/scripts/gen-index-yml/gen_index_yml.py b/scripts/gen-index-yml/gen_index_yml.py deleted file mode 100644 index c2dd32d51..000000000 --- a/scripts/gen-index-yml/gen_index_yml.py +++ /dev/null @@ -1,65 +0,0 @@ -import os -import argparse -import yaml - -DEFAULT_SRC_PATH = 'charts' -DEFAULT_YAML_PATH = 'charts.yaml' -DEFAULT_ROOT_KEY = 'charts' - -def list_subfolders(folder_path): - """ - List subfolders and return a dict, each key is a folder name - """ - return {f.name for f in os.scandir(folder_path) if f.is_dir()} - - -def load_existing_yaml(file_path): - """ - Load an existing charts yml or return an empty one - """ - default_charts = {'charts': {}} - try: - with open(file_path, 'r', encoding="utf-8") as yaml_file: - existing_file_data = yaml.safe_load(yaml_file) - return existing_file_data if existing_file_data else default_charts - except FileNotFoundError: - return default_charts - - -def write_yaml_file(data, file_path): - """ - Dump yaml to disk - """ - with open(file_path, 'w', encoding="utf-8") as yaml_file: - yaml.dump(data, yaml_file, default_flow_style=False) - - -def main(): - """ - Enumerate subfolders in a given folder, update a dictionary where each key - is the name of a subfolder in a given yaml file - """ - parser = argparse.ArgumentParser( - description='Create or update a YAML file with subfolder names.') - - parser.add_argument('--src', default=DEFAULT_SRC_PATH, - help='Path to the folder containing subfolders.') - parser.add_argument('--yaml', default=DEFAULT_YAML_PATH, - help='Path to the YAML file to write.') - parser.add_argument('--root-name', default=DEFAULT_ROOT_KEY, - help='The root key inside the YAML file') - - args = parser.parse_args() - - subfolders = list_subfolders(args.src) - data = {args.root_name: subfolders} - - existing_data = load_existing_yaml(args.yaml) - for entry in data[args.root_name]: - existing_data[args.root_name].setdefault(entry) - - write_yaml_file(existing_data, args.yaml) - - -if __name__ == "__main__": - main() diff --git a/scripts/gen-index-yml/requirements.txt b/scripts/gen-index-yml/requirements.txt deleted file mode 100644 index be2b74db4..000000000 --- a/scripts/gen-index-yml/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -PyYAML==6.0.1