Skip to content

Commit

Permalink
backend/enh/docker-push-for-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
vsaimanohar committed Sep 20, 2024
1 parent 1afc3eb commit a429f8f
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
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

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"

0 comments on commit a429f8f

Please sign in to comment.