Skip to content

Commit 2a0dbde

Browse files
committed
Build and push kmake image to AWS ECR
This change adds a workflow to build the kmake Docker image and push it to AWS Elastic Container Registry (ECR). The image will be available for use in pre-merge Docker pulls, ensuring consistent environments during testing and integration. Signed-off-by: Vishal Kumar <viskuma@qti.qualcomm.com>
1 parent 8b1892f commit 2a0dbde

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build and Push Kmake Image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
GIT_REPO_URL:
7+
description: 'GitHub repository URL to clone'
8+
required: false
9+
type: string
10+
default: https://github.com/qualcomm-linux/kmake-image.git
11+
DOCKERFILE_PATH:
12+
description: 'Path to the Dockerfile'
13+
required: false
14+
type: string
15+
default: Dockerfile
16+
TECH_TEAM_NAMESPACE:
17+
description: 'Tech team namespace for the image'
18+
required: false
19+
type: string
20+
default: kernel
21+
IMAGE_NAME:
22+
description: 'Name of the image to be built'
23+
required: false
24+
type: string
25+
default: kmake-image
26+
IMAGE_TAG:
27+
description: 'Docker image tag to use for the build'
28+
required: false
29+
type: string
30+
default: ver.1.0
31+
ENVIRONMENT_VALUE:
32+
description: 'Environment tag for the repository (prod/stage/dev/test)'
33+
required: false
34+
type: string
35+
default: prod
36+
37+
jobs:
38+
build-and-push:
39+
runs-on:
40+
group: GHA-Kernel-SelfHosted-RG
41+
labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ]
42+
env:
43+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
44+
AWS_REGION: ${{ secrets.AWS_REGION }}
45+
steps:
46+
- name: Parse inputs
47+
run: |
48+
echo "GIT_REPO_URL=${{ inputs.GIT_REPO_URL }}" >> $GITHUB_ENV
49+
echo "DOCKERFILE_PATH=${{ inputs.DOCKERFILE_PATH }}" >> $GITHUB_ENV
50+
echo "IMAGE_REF=${{ inputs.TECH_TEAM_NAMESPACE }}/${{ inputs.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }}" >> $GITHUB_ENV
51+
52+
- name: Checkout repository
53+
run: |
54+
git clone "$GIT_REPO_URL" repo
55+
cd repo
56+
57+
- name: Build Docker image
58+
working-directory: repo
59+
run: |
60+
docker build -f "$DOCKERFILE_PATH" \
61+
-t "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REF" .
62+
63+
- name: Authenticate with AWS ECR
64+
run: |
65+
aws ecr get-login-password --region "$AWS_REGION" \
66+
| docker login --username AWS --password-stdin \
67+
"$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com"
68+
69+
- name: Ensure ECR repository exists
70+
run: |
71+
if ! aws ecr describe-repositories \
72+
--repository-names "$TECH_TEAM_NAMESPACE/$IMAGE_NAME" \
73+
--region "$AWS_REGION" \
74+
--registry-id "$AWS_ACCOUNT_ID" >/dev/null 2>&1; then
75+
echo "Repository not found, creating..."
76+
aws ecr create-repository \
77+
--region "$AWS_REGION" \
78+
--registry-id "$AWS_ACCOUNT_ID" \
79+
--repository-name "$TECH_TEAM_NAMESPACE/$IMAGE_NAME" \
80+
--tags Key=environment,Value="$ENVIRONMENT_VALUE"
81+
else
82+
echo "Repository $TECH_TEAM_NAMESPACE/$IMAGE_NAME already exists, skipping creation."
83+
fi
84+
85+
- name: Push Docker image to ECR
86+
run: |
87+
docker push "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REF"

0 commit comments

Comments
 (0)