From a48ef79b82411708585bd53180f3b172b3a8dcc7 Mon Sep 17 00:00:00 2001 From: James Jones Date: Tue, 6 Dec 2022 19:33:30 -0500 Subject: [PATCH] Adding on home registry --- .github/workflows/build.yml | 64 ++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 55c7f99..a194262 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,8 +26,16 @@ jobs: options: --userns=keep-id --privileged --user root strategy: fail-fast: false + max-parallel: 2 matrix: - language: [ 'python' ] + registry: [ 'ghcr.io', 'nexus.jamjon3.sytes.net:5443' ] + include: + - registry: ghcr.io + user: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - registry: nexus.jamjon3.sytes.net:5443 + user: ${{ secrets.HOME_NEXUS_DOCKER_USER }} + password: ${{ secrets.HOME_NEXUS_DOCKER_PASSWORD }} steps: # Downloads a copy of the code in your repository before running CI tests @@ -39,15 +47,21 @@ jobs: - name: Docker Login uses: azure/docker-login@v1 with: - login-server: ${{ env.REGISTRY }} - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - name: Docker Login - uses: azure/docker-login@v1 - with: - login-server: ${{ env.NEXUS_REGISTRY }} - username: ${{ secrets.HOME_NEXUS_DOCKER_USER }} - password: ${{ secrets.HOME_NEXUS_DOCKER_PASSWORD }} + login-server: ${{ matrix.registry }} + username: ${{ matrix.user }} + password: ${{ matrix.password }} + # - name: Docker Login + # uses: azure/docker-login@v1 + # with: + # login-server: ${{ env.REGISTRY }} + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + # - name: Docker Login + # uses: azure/docker-login@v1 + # with: + # login-server: ${{ env.NEXUS_REGISTRY }} + # username: ${{ secrets.HOME_NEXUS_DOCKER_USER }} + # password: ${{ secrets.HOME_NEXUS_DOCKER_PASSWORD }} # This requires docker buildx which podman doesn't support # - name: Extract metadata (tags, labels) for Docker # id: meta @@ -69,16 +83,30 @@ jobs: else VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') fi - podman build . --file Dockerfile --tag "$REGISTRY/$IMAGE_NAME:$VERSION" - podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" - podman push "$REGISTRY/$IMAGE_NAME:$VERSION" - podman push "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" + podman build . --file Dockerfile --tag "${{ matrix.registry }}/$IMAGE_NAME:$VERSION" + podman push "${{ matrix.registry }}/$IMAGE_NAME:$VERSION" if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then - podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$REGISTRY/$IMAGE_NAME:latest" - podman tag "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" "$NEXUS_REGISTRY/$IMAGE_NAME:latest" - podman push "$REGISTRY/$IMAGE_NAME:latest" - podman push "$NEXUS_REGISTRY/$IMAGE_NAME:latest" + podman tag "${{ matrix.registry }}/$IMAGE_NAME:$VERSION" "${{ matrix.registry }}/$IMAGE_NAME:latest" + podman push "${{ matrix.registry }}/$IMAGE_NAME:latest" fi + # - name: Build the Docker image + # run: | + # IMAGE_NAME=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') + # if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then + # VERSION=$GITHUB_REF_NAME + # else + # VERSION=$(echo "${GITHUB_REF_NAME}" | sed 's|/|-|g') + # fi + # podman build . --file Dockerfile --tag "$REGISTRY/$IMAGE_NAME:$VERSION" + # podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" + # podman push "$REGISTRY/$IMAGE_NAME:$VERSION" + # podman push "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" + # if [[ "$GITHUB_REF" =~ ^refs/tags.* ]]; then + # podman tag "$REGISTRY/$IMAGE_NAME:$VERSION" "$REGISTRY/$IMAGE_NAME:latest" + # podman tag "$NEXUS_REGISTRY/$IMAGE_NAME:$VERSION" "$NEXUS_REGISTRY/$IMAGE_NAME:latest" + # podman push "$REGISTRY/$IMAGE_NAME:latest" + # podman push "$NEXUS_REGISTRY/$IMAGE_NAME:latest" + # fi # env: # REG_TOKEN: ${{ secrets.GITHUB_TOKEN }} # # REG_TOKEN: ${{ secrets.REPO_GITHUB_TOKEN }}