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 14a4dcd
Showing 1 changed file with 25 additions and 5 deletions.
30 changes: 25 additions & 5 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
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:
build-and-push:
runs-on: x86_64-linux

steps:
- uses: actions/checkout@v4

- name: Setup Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable

- uses: cachix/cachix-action@v15
with:
name: nammayatri
Expand All @@ -26,3 +27,22 @@ jobs:

- name: Build all flake outputs
run: om ci

- name: Build and push Docker image
if: github.ref == 'refs/heads/main'
env:
GITHUB_USERNAME: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
IMAGE_PATH=$(nix build '.#dockerImage' --print-out-paths --no-update-lock-file)
docker load -i "$IMAGE_PATH"
IMAGE_NAME="ghcr.io/nammayatri/beckn-gateway"
IMAGE_TAG=$(nix eval --raw '.#dockerImage.imageTag')
FULL_IMAGE_NAME="${IMAGE_NAME}:${IMAGE_TAG}"
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "$GITHUB_USERNAME" --password-stdin
docker push "$FULL_IMAGE_NAME"
docker logout ghcr.io

0 comments on commit 14a4dcd

Please sign in to comment.