Skip to content

Commit 50d7b59

Browse files
committed
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.
1 parent da8af27 commit 50d7b59

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

.github/workflows/custom-docker-build-push.yml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ jobs:
4646
runs-on: ubuntu-latest
4747

4848
steps:
49+
# Env variables
4950
- name: Assign username from secret
5051
if: ${{ inputs.Override_Registry_Username == ''}}
5152
run: |
@@ -74,23 +75,9 @@ jobs:
7475
run: |
7576
echo "repo_name=${GITHUB_REPOSITORY#*/}" >> "$GITHUB_ENV"
7677
77-
- name: Checkout code
78-
uses: actions/checkout@v2
79-
80-
- name: Set up Docker Buildx
81-
uses: docker/setup-buildx-action@v3
82-
with:
83-
install: true
84-
85-
- name: Login to container registry
86-
uses: docker/login-action@v3
87-
with:
88-
registry: ${{ env.Registry_Base_URL }}
89-
username: ${{ env.Registry_Username }}
90-
password: ${{ env.Registry_Password }}
91-
78+
# Code
9279
- name: Checkout repository
93-
uses: actions/checkout@v2
80+
uses: actions/checkout@v4
9481
with:
9582
path: "./repo"
9683

@@ -103,11 +90,19 @@ jobs:
10390
mv ./_repo ./repo
10491
ls ./repo
10592
106-
- name: Docker Buildx setup
93+
# Docker
94+
- name: Set up Docker Buildx
10795
uses: docker/setup-buildx-action@v3
10896
with:
10997
install: true
11098

99+
- name: Login to container registry
100+
uses: docker/login-action@v3
101+
with:
102+
registry: ${{ env.Registry_Base_URL }}
103+
username: ${{ env.Registry_Username }}
104+
password: ${{ env.Registry_Password }}
105+
111106
- name: Docker Build and Push (with cache)
112107
if: ${{ fromJSON(env.Use_Build_Cache) == true }}
113108
uses: docker/build-push-action@v6

0 commit comments

Comments
 (0)