From aae6d238d32726df196291b7c0ea6e5600a7b9eb Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Mon, 23 Oct 2023 11:01:47 +0300 Subject: [PATCH] CI: separate docker build and docker publish steps --- .github/workflows/docker.yml | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 0236af6c9..73083b067 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -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: @@ -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 &&