diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dfea3af..99ac7d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,3 +49,27 @@ jobs: - name: Build run: nix build --print-build-logs + + - name: Build and push container image + if: ${{ github.ref_name == 'main' || github.ref_type == 'tag' }} + run: | + set -x + + # Build image via Nix and take the resulting path as the local container registry + local_cr="docker-archive://$(nix build .#$container-image --no-link --print-out-paths)" + + # The container registry to push images to (GHCR) + remote_cr="docker://ghcr.io/dannixon/git-collage" + remote_cr_creds="${{ github.repository_owner }}:${{ github.token }}" + + # Push image using the Git ref name as the image tag (i.e. "main" or the tag name) + skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:${{ github.ref_name }}" + + # Push image using the Git SHA as the image tag + skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:${{ github.sha }}" + + # If the trigger was a tag (i.e. a release) + if [[ "${{ github.ref_type }}" == 'tag' ]]; then + # Push image using the "latest" tag + skopeo copy --dest-creds="$remote_cr_creds" "$local_cr" "$remote_cr:latest" + fi diff --git a/examples/config.toml b/examples/sample.toml similarity index 100% rename from examples/config.toml rename to examples/sample.toml diff --git a/examples/simple_test.toml b/examples/simple_test.toml new file mode 100644 index 0000000..0fbb364 --- /dev/null +++ b/examples/simple_test.toml @@ -0,0 +1,15 @@ +[[providers]] +path = 'mirrors/misc' + +[[providers.ref_matchers.rules]] +type = 'exact' +expr = 'refs/heads/main' + +[providers.source] +type = 'static_list' + +[[providers.source.repos]] +git_url = 'https://github.com/dannixon/dotfiles' + +[[providers.source.repos]] +git_url = 'https://github.com/dannixon/git-collage' diff --git a/flake.lock b/flake.lock index 72a9b2f..59874fb 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1736061677, - "narHash": "sha256-DjkQPnkAfd7eB522PwnkGhOMuT9QVCZspDpJJYyOj60=", + "lastModified": 1736867362, + "narHash": "sha256-i/UJ5I7HoqmFMwZEH6vAvBxOrjjOJNU739lnZnhUln8=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cbd8ec4de4469333c82ff40d057350c30e9f7d36", + "rev": "9c6b49aeac36e2ed73a8c472f1546f6d9cf1addc", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 5137153..6cc72c6 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,9 @@ }; outputs = { - self, nixpkgs, flake-utils, + ... }: flake-utils.lib.eachDefaultSystem ( system: let @@ -52,7 +52,7 @@ RUSTFLAGS = "-D unused-crate-dependencies"; }; - packages = { + packages = rec { default = rustPlatform.buildRustPackage { pname = name; version = version; @@ -63,6 +63,25 @@ nativeBuildInputs = nativeBuildInputs; buildInputs = buildInputs; }; + + container-image = pkgs.dockerTools.buildImage { + name = name; + tag = "latest"; + created = "now"; + + runAsRoot = '' + #!${pkgs.runtimeShell} + mkdir -p /config + mkdir -p /data + ''; + + config = { + Entrypoint = ["${default}/bin/git-collage"]; + Env = [ + "SSL_CERT_FILE=${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt" + ]; + }; + }; }; } );