diff --git a/modules/devenv/integrations/github/skaffold.nix b/modules/devenv/integrations/github/skaffold.nix index 7967699..cc6feb1 100644 --- a/modules/devenv/integrations/github/skaffold.nix +++ b/modules/devenv/integrations/github/skaffold.nix @@ -48,6 +48,12 @@ in description = "Overrides for skaffold integration"; }; + flux-push = mkOption { + type = types.submodule { freeformType = yamlFormat.type; }; + default = { }; + description = "Overrides for the Flux OCI push of rendered manifests (repository is derived automatically)"; + }; + otel-endpoint = mkOption { type = types.str; default = ""; @@ -147,6 +153,17 @@ in // cfg.settings.checkout; } { + id = "repo"; + shell = "bash"; + run = '' + owner=''${GITHUB_REPOSITORY%%/*} + name=''${GITHUB_REPOSITORY##*/} + echo "owner=$owner" >> "$GITHUB_OUTPUT" + echo "name=$name" >> "$GITHUB_OUTPUT" + echo "repository=ghcr.io/$owner/$name/manifests/$name" >> "$GITHUB_OUTPUT" + ''; + } +{ uses = "docker/login-action@v4"; "with" = { registry = "ghcr.io"; @@ -197,6 +214,16 @@ in path = "artifacts/skaffold-manifest.yaml"; }; } + { + id = "flux-push"; + "if" = "\${{ inputs.push }}"; + uses = "shikanime-labs/actions/flux/flux-push@v9"; + "with" = { + path = "artifacts/skaffold-manifest.yaml"; + repository = "\${{ steps.repo.outputs.repository }}"; + } + // cfg.settings.flux-push; + } ]; }; @@ -233,6 +260,19 @@ in // cfg.settings.checkout; } { + id = "repo"; + shell = "bash"; + env.matrix_name = "\${{ matrix.name }}"; + run = '' + owner=''${GITHUB_REPOSITORY%%/*} + name=''${GITHUB_REPOSITORY##*/} + echo "owner=$owner" >> "$GITHUB_OUTPUT" + echo "name=$name" >> "$GITHUB_OUTPUT" + manifest_repo=''${matrix_name:-$name} + echo "repository=ghcr.io/$owner/$name/manifests/$manifest_repo" >> "$GITHUB_OUTPUT" + ''; + } +{ uses = "docker/login-action@v4"; "with" = { registry = "ghcr.io"; @@ -263,6 +303,27 @@ in } // optionalAttrs (cfg.settings.integration != { }) cfg.settings.integration; } + { + name = "Save manifest"; + env.SKAFFOLD_MANIFEST = "\${{ steps.skaffold.outputs.manifest }}"; + run = '' + mkdir -p artifacts + cat > artifacts/skaffold-manifest.yaml <<'MANIFEST_EOF' + $SKAFFOLD_MANIFEST + MANIFEST_EOF + ''; + shell = "bash"; + } + { + id = "flux-push"; + "if" = "\${{ inputs.push }}"; + uses = "shikanime-labs/actions/flux/flux-push@v9"; + "with" = { + path = "artifacts/skaffold-manifest.yaml"; + repository = "\${{ steps.repo.outputs.repository }}"; + } + // cfg.settings.flux-push; + } ]; }; }; diff --git a/modules/devenv/profiles/skaffold.nix b/modules/devenv/profiles/skaffold.nix index 1e6c354..0ae0cc2 100644 --- a/modules/devenv/profiles/skaffold.nix +++ b/modules/devenv/profiles/skaffold.nix @@ -13,5 +13,8 @@ github.workflows.skaffold.enable = true; - packages = [ pkgs.skaffold ]; + packages = [ + pkgs.skaffold + pkgs.fluxcd + ]; }