Skip to content

Commit 1417225

Browse files
authored
Push image to Docker Hub staging repository on a successful build (#717)
Signed-off-by: Govind Kamat <[email protected]>
1 parent e47a88b commit 1417225

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Docker Build
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
strategy:
11+
matrix:
12+
platform: ['linux/amd64', 'linux/arm64']
13+
steps:
14+
- name: Set up QEMU
15+
uses: docker/setup-qemu-action@v3
16+
17+
- name: Set up Docker Buildx
18+
uses: docker/setup-buildx-action@v3
19+
with:
20+
version: 'v0.9.1'
21+
- uses: actions/checkout@v4
22+
23+
- name: Configure Role to Acquire Credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
role-to-assume: ${{ secrets.BENCHMARK_DOCKERHUB_ROLE }}
27+
aws-region: us-east-1
28+
29+
- name: Retrieve Password
30+
id: retrieve-password
31+
run: |
32+
DOCKERHUB_PASSWORD=`aws secretsmanager get-secret-value --secret-id jenkins-staging-dockerhub-credential --query SecretString --output text`
33+
echo "::add-mask::$DOCKERHUB_PASSWORD"
34+
echo "dockerhub-password=$DOCKERHUB_PASSWORD" >> $GITHUB_OUTPUT
35+
36+
- name: Login to DockerHub
37+
uses: docker/login-action@v1
38+
with:
39+
username: ${{ secrets.BENCHMARK_DOCKERHUB_USERNAME }}
40+
password: ${{ steps.retrieve-password.outputs.dockerhub-password }}
41+
42+
- name: Docker Build ${{ matrix.platform }}
43+
run: |
44+
docker buildx version
45+
tag=osb/osb-`echo ${{ matrix.platform }} | tr '/' '-'`
46+
set -x
47+
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 .
48+
set +x

0 commit comments

Comments
 (0)