From a429f8f3687d8cfa4d620a71425d69bed6bab173 Mon Sep 17 00:00:00 2001 From: "saimanohar.veeravajhula" Date: Fri, 20 Sep 2024 16:45:35 +0530 Subject: [PATCH] backend/enh/docker-push-for-ci --- .github/workflows/nix.yml | 45 ++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 2c185c3..3e16a8e 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -1,16 +1,3 @@ -name: CI - -on: - # Triggers the workflow on push or pull request events but only for the "main" branch - push: - branches: ["main"] - pull_request: - branches: ["main"] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: build: runs-on: x86_64-linux @@ -18,11 +5,31 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: cachix/cachix-action@v15 + - name: Install Nix + uses: cachix/install-nix-action@v25 with: - name: nammayatri - authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}" - skipPush: true + nix_path: nixpkgs=channel:nixos-unstable + + - name: Build and push Docker image + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + # Build and load Docker image + docker load -i $(nix build .#dockerImage --no-link --print-out-paths) + + # Set image name and tag + IMAGE_NAME="ghcr.io/nammayatri/beckn-gateway" + IMAGE_TAG="${GITHUB_SHA::7}" + FULL_IMAGE_NAME="${IMAGE_NAME}:${IMAGE_TAG}" + + # Login to GitHub Container Registry + echo "$GITHUB_TOKEN" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin + + # Tag and push the image + docker tag "ghcr.io/nammayatri/beckn-gateway:a7c614" "$FULL_IMAGE_NAME" + docker push "$FULL_IMAGE_NAME" + + # Logout + docker logout ghcr.io - - name: Build all flake outputs - run: om ci + echo "Pushed image: $FULL_IMAGE_NAME" \ No newline at end of file