From 50d7b59ce139a98047ae4df360d90dcdab28a641 Mon Sep 17 00:00:00 2001 From: Ryan Inch Date: Sun, 29 Dec 2024 02:22:58 -0500 Subject: [PATCH] Refactor the custom docker build/push GitHub workflow Remove duplicate steps. Reorganize the steps into discrete sections. Both the checkout and docker buildx setup steps were present in the workflow file twice and while this didn't cause any problems running the workflow file it was confusing, unneeded (the buildx step is like installing a dependency and can happen anytime before the docker build/push step, as for the checkout step, everything was configured to use the code from the second checkout step thus making the first unnecessary), and probably slowed down its execution slightly. Removing the duplicate steps and reorganizing the rest makes everything simpler and clearer. --- .../workflows/custom-docker-build-push.yml | 29 ++++++++----------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/.github/workflows/custom-docker-build-push.yml b/.github/workflows/custom-docker-build-push.yml index f040a3ea80..30156e0193 100644 --- a/.github/workflows/custom-docker-build-push.yml +++ b/.github/workflows/custom-docker-build-push.yml @@ -46,6 +46,7 @@ jobs: runs-on: ubuntu-latest steps: + # Env variables - name: Assign username from secret if: ${{ inputs.Override_Registry_Username == ''}} run: | @@ -74,23 +75,9 @@ jobs: run: | echo "repo_name=${GITHUB_REPOSITORY#*/}" >> "$GITHUB_ENV" - - name: Checkout code - uses: actions/checkout@v2 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - with: - install: true - - - name: Login to container registry - uses: docker/login-action@v3 - with: - registry: ${{ env.Registry_Base_URL }} - username: ${{ env.Registry_Username }} - password: ${{ env.Registry_Password }} - + # Code - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: path: "./repo" @@ -103,11 +90,19 @@ jobs: mv ./_repo ./repo ls ./repo - - name: Docker Buildx setup + # Docker + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: install: true + - name: Login to container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.Registry_Base_URL }} + username: ${{ env.Registry_Username }} + password: ${{ env.Registry_Password }} + - name: Docker Build and Push (with cache) if: ${{ fromJSON(env.Use_Build_Cache) == true }} uses: docker/build-push-action@v6