Skip to content

Commit 4e84280

Browse files
committed
add workflow to publish api image from feat/add-api
1 parent fb96b27 commit 4e84280

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Docker Image API
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "feat/add-api"
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
IMAGE_NAME: ${{ github.repository }}
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
if: github.actor != 'dependabot[bot]'
17+
permissions:
18+
contents: read
19+
packages: write
20+
id-token: write
21+
22+
steps:
23+
- name: Checkout repository
24+
uses: actions/checkout@v6
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Get version from git
29+
id: get-version
30+
run: |
31+
VERSION=$(git describe --tags 2>/dev/null || echo "dev")
32+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
33+
echo "Using version: $VERSION"
34+
35+
- name: Setup Docker buildx
36+
uses: docker/setup-buildx-action@v4
37+
38+
- name: Set up QEMU
39+
uses: docker/setup-qemu-action@v4
40+
41+
- name: Extract Docker metadata tags
42+
id: meta
43+
uses: docker/metadata-action@v6
44+
with:
45+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
46+
tags: |
47+
type=raw,value=api
48+
49+
- name: Log into registry ${{ env.REGISTRY }}
50+
uses: docker/login-action@v4
51+
with:
52+
registry: ${{ env.REGISTRY }}
53+
username: ${{ github.repository_owner }}
54+
password: ${{ secrets.GITHUB_TOKEN }}
55+
56+
- name: Build and push Docker image
57+
id: build-and-push
58+
uses: docker/build-push-action@v7
59+
with:
60+
context: .
61+
push: true
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+
provenance: false
67+
platforms: linux/amd64,linux/arm64
68+
build-args: |
69+
VERSION=${{ steps.get-version.outputs.VERSION }}

0 commit comments

Comments
 (0)