From 402f3aa65022ff4ef88b16def2c7c5308f6e8bb0 Mon Sep 17 00:00:00 2001 From: frectonz Date: Sat, 19 Oct 2024 13:28:33 +0300 Subject: [PATCH] feat: deploy docker image on release --- .github/workflows/image.yml | 25 +++++++++++++++++++++++++ flake.nix | 20 +++++++++----------- 2 files changed, 34 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/image.yml diff --git a/.github/workflows/image.yml b/.github/workflows/image.yml new file mode 100644 index 0000000..a008fb7 --- /dev/null +++ b/.github/workflows/image.yml @@ -0,0 +1,25 @@ +name: Publish Docker Image + +on: + push: + tags: + - '**[0-9]+.[0-9]+.[0-9]+*' + +jobs: + build: + runs-on: ubuntu-24.04 + + permissions: + contents: read + id-token: write + + env: + ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }} + + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Deploy Docker Image + run: nix run .#deploy diff --git a/flake.nix b/flake.nix index 9cbad51..a443d34 100644 --- a/flake.nix +++ b/flake.nix @@ -58,25 +58,23 @@ ''; }); - docker = pkgs.dockerTools.streamLayeredImage { + docker = pkgs.dockerTools.buildLayeredImage { name = "sql-studio"; tag = "latest"; created = "now"; - config.Cmd = [ - "${bin}/bin/sql-studio" - "--no-browser" - "--no-shutdown" - "--address=0.0.0.0:3030" - "sqlite" - "preview" - ]; - config.Expose = "3030"; + contents = [ bin ]; }; + + version = "0.1.28"; + deploy = pkgs.writeShellScriptBin "deploy" '' + ${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker-archive:${docker} docker://docker.io/frectonz/sql-studio:${version} --dest-creds="frectonz:$ACCESS_TOKEN" + ${pkgs.skopeo}/bin/skopeo --insecure-policy copy docker://docker.io/frectonz/sql-studio:${version} docker://docker.io/frectonz/sql-studio:latest --dest-creds="frectonz:$ACCESS_TOKEN" + ''; in { packages = { + inherit deploy docker; default = bin; - docker = docker; stable = pkgs.callPackage ./package.nix { }; };