Skip to content

Commit 907b332

Browse files
committed
Push image to Docker Hub staging repository on a successful build.
Signed-off-by: Govind Kamat <govkamat@amazon.com>
1 parent 477aad9 commit 907b332

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

.github/workflows/docker-build.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,29 @@ jobs:
2929
version: 'v0.9.1'
3030
- uses: actions/checkout@v4
3131

32+
- name: Configure Role to Acquire Credentials
33+
uses: aws-actions/configure-aws-credentials@v4
34+
with:
35+
role-to-assume: ${{ secrets.BENCHMARK_DOCKERHUB_ROLE }}
36+
aws-region: us-east-1
37+
38+
- name: Retrieve Password
39+
id: retrieve-password
40+
run: |
41+
DOCKERHUB_PASSWORD=`aws secretsmanager get-secret-value --secret-id jenkins-staging-dockerhub-credential --query SecretString --output text`
42+
echo "::add-mask::$DOCKERHUB_PASSWORD"
43+
echo "dockerhub-password=$DOCKERHUB_PASSWORD" >> $GITHUB_OUTPUT
44+
45+
- name: Login to DockerHub
46+
uses: docker/login-action@v1
47+
with:
48+
username: ${{ secrets.BENCHMARK_DOCKERHUB_USERNAME }}
49+
password: ${{ steps.retrieve-password.outputs.dockerhub-password }}
50+
3251
- name: Docker Build ${{ matrix.platform }}
3352
run: |
3453
docker buildx version
3554
tag=osb/osb-`echo ${{ matrix.platform }} | tr '/' '-'`
3655
set -x
37-
docker buildx build --platform ${{ matrix.platform }} --build-arg VERSION=`cat version.txt` --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f docker/Dockerfile -t "$tag" -o type=docker .
56+
docker buildx build --platform ${{ matrix.platform }} --build-arg VERSION=`cat version.txt` --build-arg BUILD_DATE=`date -u +%Y-%m-%dT%H:%M:%SZ` -f docker/Dockerfile -t "$tag" --push .
3857
set +x
39-
docker images | grep "$tag"

0 commit comments

Comments
 (0)