Skip to content

backend/enh/docker-push-for-ci #12

backend/enh/docker-push-for-ci

backend/enh/docker-push-for-ci #12

Workflow file for this run

name: CI
on:
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-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
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
skipPush: true
- 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