Skip to content

Commit 3a40272

Browse files
committed
Resolve some issues with the combine manifests job
1 parent 362fad6 commit 3a40272

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

.github/workflows/earthly-build.yaml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,7 @@ jobs:
6666
sudo wget https://github.com/earthly/earthly/releases/latest/download/earthly-linux-${{ matrix.arch }} -O /usr/local/bin/earthly
6767
sudo chmod 755 /usr/local/bin/earthly
6868
69-
- name: Login to Docker Hub
70-
uses: docker/login-action@v3
71-
with:
72-
username: ${{ env.DOCKER_HUB_USERNAME }}
73-
password: ${{ secrets.DOCKER_HUB_RW_TOKEN }}
74-
75-
- name: Build spaceros image and push it to Dockerhub
76-
id: push_image
69+
- name: Build spaceros image without pushing
7770
run: |
7871
earthly --ci --output +push-main-image \
7972
--VCS_REF="$VCS_REF" \
@@ -96,20 +89,26 @@ jobs:
9689
docker tag "$DOCKER_HUB_IMAGE_NAME:$ARCH_IMAGE_TAG" "$GHCR_IMAGE_NAME:$ARCH_IMAGE_TAG"
9790
docker push "$GHCR_IMAGE_NAME:$ARCH_IMAGE_TAG"
9891
92+
# Push both tagged releases and the latest main builds to Dockerhub
93+
- name: Push spaceros images to Dockerhub
94+
if: ${{ github.ref_type == 'tag' || github.ref_name == 'main' }}
95+
id: push_image
96+
env:
97+
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_RW_TOKEN }}
98+
run: |
99+
# We must login using the password and not the action, as the action only supports tokens.
100+
echo "$DOCKER_HUB_TOKEN" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
101+
docker push "$DOCKER_HUB_IMAGE_NAME:$IMAGE_TAG"
102+
echo "output_${{ matrix.arch }}=$DOCKER_HUB_IMAGE_NAME:$ARCH_IMAGE_TAG" >> "$GITHUB_OUTPUT"
103+
99104
100105
combine-main-image-manifests:
106+
needs: space-ros-main-image
107+
# If we've pushed a main image
108+
if: ${{ join(needs.space-ros-main-image.outputs, '') != '' }}
101109
env:
102110
IMAGE_TAG: "${{ github.head_ref || github.ref_name }}"
103-
104-
runs-on: ubuntu-latest
105-
needs: space-ros-main-image
106111
steps:
107-
- name: Login to Docker Hub
108-
uses: docker/login-action@v3
109-
with:
110-
username: ${{ env.DOCKER_HUB_USERNAME }}
111-
password: ${{ secrets.DOCKER_HUB_RW_TOKEN }}
112-
113112
- name: Combine Manifests
114113
run: |
115114
docker manifest create osrf/space-ros:${{ github.ref_name }} \
@@ -119,11 +118,15 @@ jobs:
119118
# Any tagged image should also be marked as "latest"
120119
- name: Push spaceros latest images to Dockerhub
121120
if: ${{ github.ref_type == 'tag' }}
121+
env:
122+
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_RW_TOKEN }}
122123
run: |
123124
# We must login using the password and not the action, as the action only supports tokens.
125+
echo "$DOCKER_HUB_TOKEN" | docker login --username "$DOCKER_HUB_USERNAME" --password-stdin
124126
docker tag "$DOCKER_HUB_IMAGE_NAME:$IMAGE_TAG" "$DOCKER_HUB_IMAGE_NAME:latest"
125127
docker push "$DOCKER_HUB_IMAGE_NAME:latest"
126128
129+
127130
space-ros-dev-image:
128131
runs-on: ubuntu-latest
129132
env:

0 commit comments

Comments
 (0)