Skip to content

Commit

Permalink
Refactor the custom docker build/push GitHub workflow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Exairnous committed Dec 29, 2024
1 parent da8af27 commit 50d7b59
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions .github/workflows/custom-docker-build-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
runs-on: ubuntu-latest

steps:
# Env variables
- name: Assign username from secret
if: ${{ inputs.Override_Registry_Username == ''}}
run: |
Expand Down Expand Up @@ -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"

Expand All @@ -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
Expand Down

0 comments on commit 50d7b59

Please sign in to comment.