Skip to content

Commit

Permalink
CI: separate docker build and docker publish steps
Browse files Browse the repository at this point in the history
  • Loading branch information
NotAShelf committed Oct 23, 2023
1 parent 3599cef commit aae6d23
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
name: "Publish Docker Image"

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
USERNAME: "${{ github.actor }}"
PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
IMAGE_NAME: "${{ github.repository }}"

on:
pull_request:
Expand Down Expand Up @@ -32,22 +33,36 @@ jobs:
uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/magic-nix-cache-action@main

- name: Build Exposed Docker Image
run: nix build .#docker-nix --print-build-logs

publish-to-dockerhub:
name: "Publish Docker Image (Dockerhub)"
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Log into ghcr
uses: docker/login-action@master
with:
registry: "${{ env.REGISTRY }}"
username: "${{ github.actor }}"
password: "${{ secrets.GITHUB_TOKEN }}"

- name: Build Exposed Docker Image
run: nix build .#docker-nix --print-build-logs
username: "${{ env.USERNAME }}"
password: "${{ env.PASSWORD }}"

- name: Publish Docker Image
run: |
#!/usr/bin/env bash
set -eu
docker login "${{ env.REGISTRY }}" --username "${{ github.actor}}" --password "${{ secrets.GITHUB_TOKEN}}"
docker login "docker.io" \
--username "${{ env.USERNAME}}" \
--password "${{ env.PASSWORD }}"
# load the built image
docker load -i result &&
Expand Down

0 comments on commit aae6d23

Please sign in to comment.