Skip to content

Commit da45166

Browse files
committed
added build action
1 parent f47437e commit da45166

File tree

1 file changed

+77
-0
lines changed

1 file changed

+77
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Build Hello World App Image
2+
3+
on:
4+
push:
5+
branches:
6+
- app-8821-hello-kafka-sample
7+
paths:
8+
- 'quickstart/hello_world/**'
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: 'app-8821-hello-kafka-sample'
16+
17+
permissions:
18+
contents: read
19+
packages: write
20+
21+
env:
22+
REGISTRY: ghcr.io
23+
IMAGE_NAME: atlanhq/atlan-hello-world-app-main
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 up Docker Buildx
37+
uses: docker/setup-buildx-action@v3
38+
39+
- name: Log in to GitHub Container Registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ${{ env.REGISTRY }}
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
46+
- name: Extract metadata (tags, labels)
47+
id: meta
48+
uses: docker/metadata-action@v5
49+
with:
50+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
51+
tags: |
52+
type=ref,event=branch
53+
type=sha,prefix={{branch}}-
54+
type=raw,value=latest,enable={{is_default_branch}}
55+
type=raw,value={{branch}}-latest
56+
57+
- name: Build and push Docker image
58+
uses: docker/build-push-action@v5
59+
with:
60+
context: ./quickstart/hello_world
61+
file: ./quickstart/hello_world/Dockerfile
62+
push: true
63+
tags: ${{ steps.meta.outputs.tags }}
64+
labels: ${{ steps.meta.outputs.labels }}
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
platforms: linux/amd64,linux/arm64
68+
69+
- name: Image digest
70+
run: echo "Image pushed with digest ${{ steps.build.outputs.digest }}"
71+
72+
- name: Print image tags
73+
run: |
74+
echo "🎉 Successfully built and pushed image!"
75+
echo "Tags:"
76+
echo "${{ steps.meta.outputs.tags }}"
77+

0 commit comments

Comments
 (0)