Skip to content

Commit 566d53b

Browse files
refactor(workflows): streamline Docker Hub and GCP Artifact Registry integration (#2326)
- Consolidate Docker Hub and Google Artifact Registry login steps in both CPU and GPU workflows. - Replace separate build variable setup with a combined tag processing step for streamlined image tagging. - Ensure both Docker Hub and GCP images are built and pushed in a single step, enhancing efficiency. This update improves the clarity and maintainability of the CI/CD workflows. Co-authored-by: Paweł Pęczek <146137186+PawelPeczek-Roboflow@users.noreply.github.com>
1 parent 32f044e commit 566d53b

2 files changed

Lines changed: 52 additions & 64 deletions

File tree

.github/workflows/docker.cpu.yml

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
id-token: write
3232
contents: read
3333
steps:
34-
- name: Login to Docker Hub
35-
uses: docker/login-action@v3
36-
with:
37-
username: ${{ secrets.DOCKERHUB_USERNAME }}
38-
password: ${{ secrets.DOCKERHUB_TOKEN }}
3934
- name: Checkout
4035
uses: actions/checkout@v4
4136
- name: Read version from file
@@ -51,49 +46,47 @@ jobs:
5146
token: ${{ secrets.GITHUB_TOKEN }}
5247
- name: Set up Depot CLI
5348
uses: depot/setup-action@v1
54-
- name: Build and Push
55-
uses: depot/build-push-action@v1
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v3
5651
with:
57-
push: ${{ github.event_name == 'release' || (github.event.inputs.force_push == 'true') }}
58-
project: grl7ffzxd7
59-
tags: ${{ steps.tags.outputs.image_tags }}
60-
platforms: linux/amd64,linux/arm64
61-
file: ${{ env.DOCKERFILE }}
62-
63-
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
6454
- name: Authenticate gcloud
65-
uses: 'google-github-actions/auth@v2'
55+
uses: google-github-actions/auth@v2
6656
id: auth
6757
with:
68-
workload_identity_provider: 'projects/878913763597/locations/global/workloadIdentityPools/github-actions/providers/github'
69-
service_account: 'gha-inference@roboflow-staging.iam.gserviceaccount.com'
70-
token_format: 'access_token'
58+
workload_identity_provider: "projects/878913763597/locations/global/workloadIdentityPools/github-actions/providers/github"
59+
service_account: "gha-inference@roboflow-staging.iam.gserviceaccount.com"
60+
token_format: access_token
7161
- name: Login to Google Artifact Registry
7262
uses: docker/login-action@v3
7363
with:
7464
registry: us-docker.pkg.dev
7565
username: oauth2accesstoken
7666
password: ${{ steps.auth.outputs.access_token }}
77-
- name: Set up build variables
78-
id: set_up_build_variables
67+
- name: Combine Docker Hub and Artifact Registry tags
68+
id: all_tags
7969
run: |
80-
TAGS=""
81-
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.image_tags }}"
82-
for tag in "${TAG_ARRAY[@]}"; do
83-
if [ -n "$TAGS" ]; then
84-
TAGS="${TAGS}","us-docker.pkg.dev/roboflow-artifacts/${tag}"
85-
else
86-
TAGS="us-docker.pkg.dev/roboflow-artifacts/${tag}"
87-
fi
88-
done
89-
echo "PROCESSED_TAGS=${TAGS}" >> "$GITHUB_OUTPUT"
90-
echo "GCP artifacts to be pushed:"
91-
echo "$TAGS"
92-
- name: Build and push CPU image to GCP Artifact Registry
70+
DH_TAGS="${{ steps.tags.outputs.image_tags }}"
71+
GCP_PREFIX="us-docker.pkg.dev/roboflow-artifacts/"
72+
GCP_TAGS=""
73+
IFS=',' read -ra TAG_ARRAY <<< "$DH_TAGS"
74+
for tag in "${TAG_ARRAY[@]}"; do
75+
[ -z "$tag" ] && continue
76+
if [ -n "$GCP_TAGS" ]; then
77+
GCP_TAGS="${GCP_TAGS},${GCP_PREFIX}${tag}"
78+
else
79+
GCP_TAGS="${GCP_PREFIX}${tag}"
80+
fi
81+
done
82+
echo "all_tags=${DH_TAGS},${GCP_TAGS}" >> "$GITHUB_OUTPUT"
83+
echo "Single build will push to Docker Hub and Artifact Registry:"
84+
echo "${DH_TAGS},${GCP_TAGS}"
85+
- name: Build and push (Docker Hub and GCP from one build)
9386
uses: depot/build-push-action@v1
9487
with:
9588
push: ${{ github.event_name == 'release' || (github.event.inputs.force_push == 'true') }}
9689
project: grl7ffzxd7
97-
tags: ${{ steps.set_up_build_variables.outputs.PROCESSED_TAGS }}
98-
platforms: linux/amd64
90+
tags: ${{ steps.all_tags.outputs.all_tags }}
91+
platforms: linux/amd64,linux/arm64
9992
file: ${{ env.DOCKERFILE }}

.github/workflows/docker.gpu.yml

Lines changed: 24 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,6 @@ jobs:
3131
id-token: write
3232
contents: read
3333
steps:
34-
- name: Login to Docker Hub
35-
uses: docker/login-action@v3
36-
with:
37-
username: ${{ secrets.DOCKERHUB_USERNAME }}
38-
password: ${{ secrets.DOCKERHUB_TOKEN }}
3934
- name: Checkout
4035
uses: actions/checkout@v4
4136
- name: Read version from file
@@ -51,47 +46,47 @@ jobs:
5146
token: ${{ secrets.GITHUB_TOKEN }}
5247
- name: Set up Depot CLI
5348
uses: depot/setup-action@v1
54-
- name: Build and Push
55-
uses: depot/build-push-action@v1
49+
- name: Login to Docker Hub
50+
uses: docker/login-action@v3
5651
with:
57-
push: ${{ github.event_name == 'release' || (github.event.inputs.force_push == 'true') }}
58-
project: grl7ffzxd7
59-
tags: ${{ steps.tags.outputs.image_tags }}
60-
platforms: linux/amd64
61-
file: ${{ env.DOCKERFILE }}
62-
- name: 'Authenticate gcloud'
63-
uses: 'google-github-actions/auth@v2'
52+
username: ${{ secrets.DOCKERHUB_USERNAME }}
53+
password: ${{ secrets.DOCKERHUB_TOKEN }}
54+
- name: Authenticate gcloud
55+
uses: google-github-actions/auth@v2
6456
id: auth
6557
with:
66-
workload_identity_provider: 'projects/878913763597/locations/global/workloadIdentityPools/github-actions/providers/github'
67-
service_account: 'gha-inference@roboflow-staging.iam.gserviceaccount.com'
68-
token_format: 'access_token'
58+
workload_identity_provider: "projects/878913763597/locations/global/workloadIdentityPools/github-actions/providers/github"
59+
service_account: "gha-inference@roboflow-staging.iam.gserviceaccount.com"
60+
token_format: access_token
6961
- name: Login to Google Artifact Registry
7062
uses: docker/login-action@v3
7163
with:
7264
registry: us-docker.pkg.dev
7365
username: oauth2accesstoken
7466
password: ${{ steps.auth.outputs.access_token }}
75-
- name: Set up build variables
76-
id: set_up_build_variables
67+
- name: Combine Docker Hub and Artifact Registry tags
68+
id: all_tags
7769
run: |
78-
TAGS=""
79-
IFS=',' read -ra TAG_ARRAY <<< "${{ steps.tags.outputs.image_tags }}"
70+
DH_TAGS="${{ steps.tags.outputs.image_tags }}"
71+
GCP_PREFIX="us-docker.pkg.dev/roboflow-artifacts/"
72+
GCP_TAGS=""
73+
IFS=',' read -ra TAG_ARRAY <<< "$DH_TAGS"
8074
for tag in "${TAG_ARRAY[@]}"; do
81-
if [ -n "$TAGS" ]; then
82-
TAGS="${TAGS}","us-docker.pkg.dev/roboflow-artifacts/${tag}"
75+
[ -z "$tag" ] && continue
76+
if [ -n "$GCP_TAGS" ]; then
77+
GCP_TAGS="${GCP_TAGS},${GCP_PREFIX}${tag}"
8378
else
84-
TAGS="us-docker.pkg.dev/roboflow-artifacts/${tag}"
79+
GCP_TAGS="${GCP_PREFIX}${tag}"
8580
fi
8681
done
87-
echo "PROCESSED_TAGS=${TAGS}" >> "$GITHUB_OUTPUT"
88-
echo "GCP artifacts to be pushed:"
89-
echo "$TAGS"
90-
- name: Build and push GPU image to GCP Artifact Registry
82+
echo "all_tags=${DH_TAGS},${GCP_TAGS}" >> "$GITHUB_OUTPUT"
83+
echo "Single build will push to Docker Hub and Artifact Registry:"
84+
echo "${DH_TAGS},${GCP_TAGS}"
85+
- name: Build and push (Docker Hub and GCP from one build)
9186
uses: depot/build-push-action@v1
9287
with:
9388
push: ${{ github.event_name == 'release' || (github.event.inputs.force_push == 'true') }}
9489
project: grl7ffzxd7
95-
tags: ${{ steps.set_up_build_variables.outputs.PROCESSED_TAGS }}
90+
tags: ${{ steps.all_tags.outputs.all_tags }}
9691
platforms: linux/amd64
9792
file: ${{ env.DOCKERFILE }}

0 commit comments

Comments
 (0)