From fa04dcce771578c3309158f31a8e1bd13c13965c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jann=20M=C3=BCller?= Date: Wed, 8 Jan 2025 12:17:36 +0100 Subject: [PATCH] Tags for PR and release --- .github/workflows/ci-oci.yaml | 29 +++++++++++++++++++++++------ nix/containers.nix | 8 +++++--- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-oci.yaml b/.github/workflows/ci-oci.yaml index b60dec0..402e62a 100644 --- a/.github/workflows/ci-oci.yaml +++ b/.github/workflows/ci-oci.yaml @@ -6,8 +6,8 @@ name: "ci-oci" on: pull_request: push: - branches: - - main + tags: + - "v*" permissions: packages: write @@ -23,8 +23,24 @@ concurrency: jobs: tests: + strategy: + matrix: + image: [wst, wst-poc-mock-server] runs-on: ubuntu-latest steps: + + - name: Determine image tag for git tag + if: ${{ github.event_name == 'push' }} + run: | + IMAGE_TAG=$(git rev-parse --abbrev-ref "${{ github.event.push.ref }}") + echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV + + - name: Determine image tag for PR + if: ${{ github.event_name == 'pull_request' }} + run: | + IMAGE_TAG=pr-${{ github.event.pull_request.number }} + echo "IMAGE_TAG=${IMAGE_TAG}" >> $GITHUB_ENV + - name: Log in to ghcr.io uses: redhat-actions/podman-login@v1 with: @@ -60,11 +76,12 @@ jobs: # TODO: matrix build for two images (mock server and wst) - name: Build image with nix - run: nix build --accept-flake-config .#containers.x86_64-linux.wst.copyTo - - name: Publish image with podman + run: nix build --accept-flake-config .#containers.x86_64-linux.${{ matrix.image }}.copyTo + - name: Publish tagged image with podman run: | + IMAGE_NAME=ghcr.io/${{github.repository_owner}}/${{ matrix.image }}:$IMAGE_TAG ./result/bin/copy-to oci-archive:oci.tar - podman import oci.tar ghcr.io/input-output-hk/wst-test:unstable - podman push ghcr.io/input-output-hk/wst-test:unstable + podman import oci.tar $IMAGE_NAME + podman push $IMAGE_NAME diff --git a/nix/containers.nix b/nix/containers.nix index b6fb675..10b0c2d 100644 --- a/nix/containers.nix +++ b/nix/containers.nix @@ -18,8 +18,10 @@ staticFiles = pkgs.buildEnv { # the actual payload we want staticFilesDerivation # allow interactivity with the image - pkgs.bashInteractive - pkgs.coreutils + # NOTE: Uncomment the lines below if you need a shell inside the image + # (for example when debugging the image contents) + # pkgs.bashInteractive + # pkgs.coreutils ]; pathsToLink = [ "/html" "/bin" ]; extraOutputsToInstall = [ "/html" ]; @@ -78,7 +80,7 @@ in rec { # sourceUrl = "https://github.com/input-output-hk/wsc-poc"; # }; - mockserver = lib.iogx.mkContainerFromCabalExe { + wst-poc-mock-server = lib.iogx.mkContainerFromCabalExe { exe = inputs.self.packages.wst-poc-mock-server; name = "wst-poc-mock-server"; description = "WST mockserver";