Skip to content

Commit 105818a

Browse files
authored
Merge pull request #7 from cloud-py-api/fix/docker-build
fix: update Docker build/publish process
2 parents 3a05cdc + dbeec19 commit 105818a

File tree

3 files changed

+96
-3
lines changed

3 files changed

+96
-3
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Publish CPU
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
push_to_registry:
8+
name: Build image
9+
runs-on: ubuntu-latest
10+
if: ${{ github.repository_owner == 'cloud-py-api' }}
11+
permissions:
12+
packages: write
13+
contents: read
14+
steps:
15+
- name: Set app env
16+
run: |
17+
# Split and keep last
18+
echo "APP_NAME=${GITHUB_REPOSITORY##*/}" >> $GITHUB_ENV
19+
echo "APP_VERSION=${GITHUB_REF##*/}" >> $GITHUB_ENV
20+
21+
- name: Checkout
22+
uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3
23+
with:
24+
path: ${{ env.APP_NAME }}
25+
26+
- name: Read package.json node and npm engines version
27+
uses: skjnldsv/read-package-engines-version-actions@0ce2ed60f6df073a62a77c0a4958dd0fc68e32e7 # v2.1
28+
id: versions
29+
# Continue if no package.json
30+
continue-on-error: true
31+
with:
32+
path: ${{ env.APP_NAME }}
33+
fallbackNode: "^20"
34+
fallbackNpm: "^10"
35+
36+
- name: Set up node ${{ steps.versions.outputs.nodeVersion }}
37+
# Skip if no package.json
38+
if: ${{ steps.versions.outputs.nodeVersion }}
39+
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3
40+
with:
41+
node-version: ${{ steps.versions.outputs.nodeVersion }}
42+
43+
- name: Set up npm ${{ steps.versions.outputs.npmVersion }}
44+
# Skip if no package.json
45+
if: ${{ steps.versions.outputs.npmVersion }}
46+
run: npm i -g npm@"${{ steps.versions.outputs.npmVersion }}"
47+
48+
- name: Build ${{ env.APP_NAME }}
49+
# Skip if no package.json
50+
if: ${{ steps.versions.outputs.nodeVersion }}
51+
run: |
52+
cd ${{ env.APP_NAME }}
53+
npm ci
54+
npm run build
55+
56+
- name: Set up QEMU
57+
uses: docker/setup-qemu-action@v3
58+
- name: Set up Docker Buildx
59+
uses: docker/setup-buildx-action@v3
60+
61+
- name: Log in to GitHub Container Registry
62+
uses: docker/login-action@v3
63+
with:
64+
registry: ghcr.io
65+
username: ${{ github.actor }}
66+
password: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Available platforms
69+
run: echo ${{ steps.buildx.outputs.platforms }}
70+
71+
- name: Install xmlstarlet
72+
run: sudo apt-get update && sudo apt-get install -y xmlstarlet
73+
74+
- name: Extract version from XML
75+
id: extract_version
76+
run: |
77+
cd ${{ env.APP_NAME }}
78+
VERSION=$(xmlstarlet sel -t -v "//image-tag" appinfo/info.xml)
79+
echo "VERSION=$VERSION" >> $GITHUB_ENV
80+
81+
- name: Log version
82+
run: |
83+
echo "Extracted version: ${{ env.VERSION }}"
84+
85+
- name: Build container image
86+
uses: docker/build-push-action@v5
87+
with:
88+
push: true
89+
context: ./${{ env.APP_NAME }}
90+
platforms: linux/amd64,linux/arm64/v8
91+
tags: ghcr.io/cloud-py-api/talk_bot_ai:${{ env.VERSION }}
92+
build-args: |
93+
BUILD_TYPE=cpu

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
APP_ID := talk_bot_ai
44
APP_NAME := AssistantTalkBot
55
APP_VERSION := 3.0.0
6-
JSON_INFO := "{\"id\":\"$(APP_ID)\",\"name\":\"Assistant Talk Bot\",\"daemon_config_name\":\"manual_install\",\"version\":\"$(APP_VERSION)\",\"secret\":\"12345\",\"port\":10034,\"scopes\":[\"TALK\", \"TALK_BOT\"]}"
6+
JSON_INFO := "{\"id\":\"$(APP_ID)\",\"name\":\"Assistant Talk Bot\",\"daemon_config_name\":\"manual_install\",\"version\":\"$(APP_VERSION)\",\"secret\":\"12345\",\"port\":10034,\"scopes\":[\"ALL\"]}"
77

88
.PHONY: help
99
help:
@@ -26,6 +26,7 @@ help:
2626
.PHONY: build-push
2727
build-push:
2828
docker login ghcr.io
29+
docker buildx create --name $(APP_ID) --driver docker-container --platform linux/amd64,linux/arm64/v8 --use || true
2930
docker buildx build --push --platform linux/arm64/v8,linux/amd64 --tag ghcr.io/cloud-py-api/$(APP_ID):$(APP_VERSION) --tag ghcr.io/cloud-py-api/$(APP_ID):latest .
3031

3132
.PHONY: run

appinfo/info.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ Refer to [How to install](https://github.com/cloud-py-api/talk_bot_ai/blob/main/
3232
<image-tag>3.0.0</image-tag>
3333
</docker-install>
3434
<scopes>
35-
<value>TALK</value>
36-
<value>TALK_BOT</value>
35+
<value>ALL</value>
3736
</scopes>
3837
<system>false</system>
3938
</external-app>

0 commit comments

Comments
 (0)