Skip to content

Commit 970fa6a

Browse files
committed
ci: Added action for dockerhub
1 parent 75f0c66 commit 970fa6a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Multi-Platform Docker Build
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
build-and-publish:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
# Step 1: Check out the repository and submodules
12+
- name: Check out code
13+
uses: actions/checkout@v3
14+
with:
15+
submodules: true # Fetch submodules
16+
fetch-depth: 0 # Ensure the full history is fetched
17+
18+
# Step 2: Set up Docker Buildx
19+
- name: Set up Docker Buildx
20+
uses: docker/setup-buildx-action@v2
21+
22+
# Step 3: Install yq
23+
- name: Install yq
24+
run: |
25+
sudo apt-get update && sudo apt-get install -y wget
26+
sudo wget https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 -O /usr/bin/yq
27+
sudo chmod +x /usr/bin/yq
28+
29+
# Step 4: Extract component-version and component-name from odtp.yml
30+
- name: Extract component-version and component-name
31+
id: extract_info
32+
run: |
33+
VERSION=$(yq e '.component-version' odtp.yml)
34+
NAME=$(yq e '.component-name' odtp.yml)
35+
echo "VERSION=${VERSION}"
36+
echo "NAME=${NAME}"
37+
echo "COMPONENT_VERSION=${VERSION}" >> $GITHUB_ENV
38+
echo "COMPONENT_NAME=${NAME}" >> $GITHUB_ENV
39+
40+
# Step 5: Log in to Docker Hub
41+
- name: Log in to Docker Hub
42+
uses: docker/login-action@v2
43+
with:
44+
username: ${{ secrets.DOCKER_USERNAME }}
45+
password: ${{ secrets.DOCKER_PASSWORD }}
46+
47+
# Step 6: Build and push Docker image for multiple platforms
48+
- name: Build and push Docker image
49+
run: |
50+
IMAGE_NAME=${{ secrets.DOCKER_USERNAME }}/${{ env.COMPONENT_NAME }}
51+
docker buildx build \
52+
--platform linux/amd64,linux/arm64 \
53+
--build-arg COMPONENT_VERSION=${{ env.COMPONENT_VERSION }} \
54+
-t $IMAGE_NAME:${{ env.COMPONENT_VERSION }} \
55+
-t $IMAGE_NAME:latest \
56+
--push .

0 commit comments

Comments
 (0)