Skip to content

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

backend/enh/docker-push-for-ci

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

Workflow file for this run

name: CI
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
jobs:
build:
runs-on: x86_64-linux
outputs:
image_name: ${{ steps.image_info.outputs.image_name }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v24
- uses: cachix/cachix-action@v14
with:
name: nammayatri
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build Docker image tarball
run: |
nix build .#dockerImage
cp result image.tar
- name: Get image info
id: image_info
run: |
echo "image_name=$(nix eval --raw .#dockerImage.imageName):$(nix eval --raw .#dockerImage.imageTag)" >> $GITHUB_OUTPUT
- name: Upload Docker image tarball
uses: actions/upload-artifact@v4
with:
name: docker-image
path: image.tar
push-docker:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Download Docker image tarball
uses: actions/download-artifact@v4
with:
name: docker-image
- name: Load and push Docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "$GITHUB_TOKEN" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
docker load < image.tar
docker push ${{ needs.build.outputs.image_name }}
docker logout ghcr.io