diff --git a/.drone.yml b/.drone.yml index 1613bd8..8b4d562 100644 --- a/.drone.yml +++ b/.drone.yml @@ -20,13 +20,7 @@ steps: pull: always commands: - nix build .#nixos-runner - - echo -n "${plugin_password}" | podman login --username "${plugin_username}" --password-stdin "${plugin_registry}" - - image=$(podman load --input result | sed -n -e "s/Loaded image:.\\(.*\\)/\\1/p") - - podman images - - podman tag "${image}" "${plugin_registry}/${plugin_repository}:${DRONE_BUILD_NUMBER}-${DRONE_COMMIT_SHA:0:8}" - - podman tag "${image}" "${plugin_registry}/${plugin_repository}:latest" - - podman images - - podman logout "${plugin_registry}" + - nix run .#push-container -- result settings: registry: docker.io repository: jcollie/nixos-runner diff --git a/flake.nix b/flake.nix index 12b2c64..9c4cc60 100644 --- a/flake.nix +++ b/flake.nix @@ -362,6 +362,27 @@ }; }; }; + apps = { + push-container = + let + script = pkgs.writeScript "push-container" '' + set | grep -i plugin + set | grep -i DRONE + ls -l "''${1}" + echo -n "''${PLUGIN_PASSWORD}" | podman login --username "''${PLUGIN_USERNAME}" --password-stdin "''${PLUGIN_REGISTRY}" + image=''$(podman load --input "''${1}" | sed -n -e "s/Loaded image:.\\(.*\\)/\\1/p") + podman images + podman tag "''${image}" "''${PLUGIN_REGISTRY}/''${PLUGIN_REPOSITORY}:''${DRONE_BUILD_NUMBER}-''${DRONE_COMMIT_SHA:0:8}" + podman tag "''${image}" "''${PLUGIN_REGISTRY}/''${PLUGIN_REPOSITORY}:latest" + podman images + podman logout "''${PLUGIN_REGISTRY}" + ''; + in + { + type = "app"; + program = "${script}"; + }; + }; } ) );