Skip to content

Commit 77b0887

Browse files
authored
Create build-hello-world-app.yaml
1 parent 91a965e commit 77b0887

File tree

1 file changed

+86
-0
lines changed

1 file changed

+86
-0
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Build Hello World App Image
2+
3+
on:
4+
push:
5+
branches:
6+
- workflow-obs-pkg
7+
paths:
8+
- 'utilities/workflows_observability/**'
9+
- '.github/workflows/build-hello-world-app.yaml'
10+
workflow_dispatch:
11+
inputs:
12+
branch:
13+
description: 'Branch to build from'
14+
required: false
15+
default: 'workflow-obs-pkg'
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
IMAGE_BASE_NAME: atlanhq/atlan-hello-world-app
24+
25+
jobs:
26+
build-and-push:
27+
name: Build and Push Docker Image 🐋
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- name: Set image name based on branch
37+
id: image-name
38+
run: |
39+
BRANCH_NAME="${{ github.ref_name }}"
40+
# Replace / with - in branch name for valid image name
41+
SANITIZED_BRANCH=$(echo "$BRANCH_NAME" | sed 's/\//-/g')
42+
IMAGE_NAME="${{ env.IMAGE_BASE_NAME }}-${SANITIZED_BRANCH}"
43+
echo "image_name=${IMAGE_NAME}" >> $GITHUB_OUTPUT
44+
echo "Building image: ${IMAGE_NAME}"
45+
46+
- name: Set up Docker Buildx
47+
uses: docker/setup-buildx-action@v3
48+
49+
- name: Log in to GitHub Container Registry
50+
uses: docker/login-action@v3
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.actor }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Extract metadata (tags, labels)
57+
id: meta
58+
uses: docker/metadata-action@v5
59+
with:
60+
images: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}
61+
tags: |
62+
type=ref,event=branch
63+
type=sha,prefix={{branch}}-
64+
type=raw,value=latest,enable={{is_default_branch}}
65+
type=raw,value={{branch}}-latest
66+
67+
- name: Build and push Docker image
68+
uses: docker/build-push-action@v5
69+
with:
70+
context: ./quickstart/hello_world
71+
file: ./quickstart/hello_world/Dockerfile
72+
push: true
73+
tags: ${{ steps.meta.outputs.tags }}
74+
labels: ${{ steps.meta.outputs.labels }}
75+
cache-from: type=gha
76+
cache-to: type=gha,mode=max
77+
platforms: linux/amd64,linux/arm64
78+
79+
- name: Image digest
80+
run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"
81+
82+
- name: Print image tags
83+
run: |
84+
echo "🎉 Successfully built and pushed image!"
85+
echo "Tags:"
86+
echo "${{ steps.meta.outputs.tags }}"

0 commit comments

Comments
 (0)