Skip to content

Commit 7b02cc3

Browse files
committed
Add actions workflow
1 parent 80e54f4 commit 7b02cc3

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: Build and Publish Docker Image
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- 'v*.*.*'
10+
pull_request:
11+
branches:
12+
- main
13+
- master
14+
workflow_dispatch:
15+
16+
env:
17+
IMAGE_NAME: llama-cpp-studio
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: read
24+
packages: write
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Set up Docker Buildx
31+
uses: docker/setup-buildx-action@v3
32+
33+
- name: Extract metadata (tags, labels)
34+
id: meta
35+
uses: docker/metadata-action@v5
36+
with:
37+
images: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
38+
tags: |
39+
type=ref,event=branch
40+
type=ref,event=pr
41+
type=semver,pattern={{version}}
42+
type=semver,pattern={{major}}.{{minor}}
43+
type=semver,pattern={{major}}
44+
type=sha
45+
type=raw,value=latest,enable={{is_default_branch}}
46+
47+
- name: Log in to GitHub Container Registry
48+
if: github.event_name != 'pull_request'
49+
uses: docker/login-action@v3
50+
with:
51+
registry: ghcr.io
52+
username: ${{ github.actor }}
53+
password: ${{ secrets.GITHUB_TOKEN }}
54+
55+
- name: Build and push Docker image
56+
uses: docker/build-push-action@v5
57+
with:
58+
context: .
59+
file: ./Dockerfile
60+
platforms: linux/amd64
61+
push: ${{ github.event_name != 'pull_request' }}
62+
tags: ${{ steps.meta.outputs.tags }}
63+
labels: ${{ steps.meta.outputs.labels }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
build-args: |
67+
BUILD_DATE=${{ github.event.repository.created_at }}
68+
VCS_REF=${{ github.sha }}
69+
VERSION=${{ github.ref_name }}
70+
71+
- name: Generate artifact attestation
72+
if: github.event_name != 'pull_request'
73+
uses: actions/attest-build-provenance@v1
74+
with:
75+
subject-name: ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
76+
subject-digest: ${{ steps.meta.outputs.digest }}
77+
push: true
78+

0 commit comments

Comments
 (0)