Skip to content

Commit 7c1a2cd

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 7c1a2cd

1 file changed

Lines changed: 83 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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+
32+
jobs:
33+
build-and-push:
34+
runs-on:
35+
group: GHA-Kernel-SelfHosted-RG
36+
labels: [ self-hosted, kernel-prd-u2404-x64-large-od-ephem ]
37+
env:
38+
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
39+
AWS_REGION: us-west-2
40+
ENVIRONMENT_VALUE: prod
41+
steps:
42+
- name: Parse inputs
43+
run: |
44+
echo "GIT_REPO_URL=${{ inputs.GIT_REPO_URL }}" >> $GITHUB_ENV
45+
echo "DOCKERFILE_PATH=${{ inputs.DOCKERFILE_PATH }}" >> $GITHUB_ENV
46+
echo "IMAGE_REF=${{ inputs.TECH_TEAM_NAMESPACE }}/${{ inputs.IMAGE_NAME }}:${{ inputs.IMAGE_TAG }}" >> $GITHUB_ENV
47+
echo "REPO_NAME=${{ inputs.TECH_TEAM_NAMESPACE }}/${{ inputs.IMAGE_NAME }}" >> $GITHUB_ENV
48+
49+
- name: Checkout repository
50+
run: |
51+
git clone "$GIT_REPO_URL" repo
52+
53+
- name: Build Docker image
54+
working-directory: repo
55+
run: |
56+
docker build -f "$DOCKERFILE_PATH" \
57+
-t "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REF" .
58+
59+
- name: Authenticate with AWS ECR
60+
run: |
61+
aws ecr get-login-password --region "$AWS_REGION" \
62+
| docker login --username AWS --password-stdin \
63+
"$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com"
64+
65+
- name: Ensure ECR repository exists
66+
run: |
67+
if ! aws ecr describe-repositories \
68+
--repository-names "$REPO_NAME" \
69+
--region "$AWS_REGION" \
70+
--registry-id "$AWS_ACCOUNT_ID" >/dev/null 2>&1; then
71+
echo "Repository not found, creating..."
72+
aws ecr create-repository \
73+
--region "$AWS_REGION" \
74+
--registry-id "$AWS_ACCOUNT_ID" \
75+
--repository-name "$REPO_NAME" \
76+
--tags Key=environment,Value="$ENVIRONMENT_VALUE"
77+
else
78+
echo "Repository $TECH_TEAM_NAMESPACE/$IMAGE_NAME already exists, skipping creation."
79+
fi
80+
81+
- name: Push Docker image to ECR
82+
run: |
83+
docker push "$AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$IMAGE_REF"

0 commit comments

Comments
 (0)