Skip to content

Commit

Permalink
add new image label
Browse files Browse the repository at this point in the history
  • Loading branch information
ARC-MX committed Jan 4, 2025
1 parent 2dbd250 commit 9b15269
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 97 deletions.
116 changes: 94 additions & 22 deletions .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,113 @@ on:
workflow_dispatch:
inputs:
username:
description: 'version of this branch'
default: 'v1.6.2'
description: 'Version of this branch'
default: 'v1.6.3'
required: true
type: string
paths:
- 'scripts/**'
- 'Dockerfile-for-github-action'
- 'requirements.txt'
- 'example.env'
- '.github/workflows/docker-image.yml'

jobs:

build:

build-per-arch:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [amd64, arm64] # 定义要支持的架构
name: Build and Push for ${{ matrix.arch }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log into Docker Hub registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image to Docker Hub
run: |
DOCKER_IMAGE=arcw/sgcc_electricity
ARCH=${{ matrix.arch }}
VERSION=${{ inputs.username }}
docker buildx build \
--platform linux/${ARCH} \
--build-arg VERSION=${VERSION} \
-t ${DOCKER_IMAGE}:latest-${ARCH} \
-t ${DOCKER_IMAGE}:${VERSION}-${ARCH} \
--file Dockerfile-for-github-action \
--push .
- name: Log into Aliyun registry
uses: docker/login-action@v2
with:
registry: registry.cn-hangzhou.aliyuncs.com
username: ${{ secrets.ALIYUN_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push Docker image to Aliyun
run: |
ALIYUN_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity
ARCH=${{ matrix.arch }}
VERSION=${{ inputs.username }}
docker buildx build \
--platform linux/${ARCH} \
--build-arg VERSION=${VERSION} \
-t ${ALIYUN_IMAGE}:latest-${ARCH} \
-t ${ALIYUN_IMAGE}:${VERSION}-${ARCH} \
--file Dockerfile-for-github-action \
--push .
# build-multi-arch:
# needs: build-per-arch
# runs-on: ubuntu-latest
# name: Build and Push Multi-Arch Image

# steps:
# - uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v2

- name: Log into docker hub registry
run: echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.DOCKER_USERNAME }} --password-stdin
# - name: Log into Docker Hub registry
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

# - name: Build and push multi-arch Docker image to Docker Hub
# run: |
# DOCKER_IMAGE=arcw/sgcc_electricity
# VERSION=${{ inputs.username }}
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# --build-arg VERSION=${VERSION} \
# -t ${DOCKER_IMAGE}:latest \
# -t ${DOCKER_IMAGE}:${VERSION} \
# --file Dockerfile-for-github-action \
# --push .

- name: Build and push Docker image
run: |
PLATFORMS=linux/arm64,linux/amd64
DOCKER_IMAGE=arcw/sgcc_electricity
docker buildx build --build-arg VERSION=${{ inputs.username }} --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push .
# - name: Log into Aliyun registry
# uses: docker/login-action@v2
# with:
# registry: registry.cn-hangzhou.aliyuncs.com
# username: ${{ secrets.ALIYUN_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}

- name: Log into Aliyun hub registry and push Docker image
run: |
echo ${{ secrets.DOCKER_PASSWORD }} | docker login -u ${{ secrets.ALIYUN_USERNAME }} --password-stdin registry.cn-hangzhou.aliyuncs.com
PLATFORMS=linux/arm64,linux/amd64
DOCKER_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity
docker buildx build --build-arg VERSION=${{ inputs.username }} --platform $PLATFORMS -t $DOCKER_IMAGE:latest -t $DOCKER_IMAGE:${{ inputs.username }} --file Dockerfile-for-github-action --push .
# - name: Build and push multi-arch Docker image to Aliyun
# run: |
# ALIYUN_IMAGE=registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity
# VERSION=${{ inputs.username }}
# docker buildx build \
# --platform linux/amd64,linux/arm64 \
# --build-arg VERSION=${VERSION} \
# -t ${ALIYUN_IMAGE}:latest \
# -t ${ALIYUN_IMAGE}:${VERSION} \
# --file Dockerfile-for-github-action \
# --push .
12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
FROM arcw/sgcc_electricity:latest
ARG BUILD_FROM
FROM $BUILD_FROM

COPY run.sh /run.sh
RUN chmod +x /run.sh
ENV SET_CONTAINER_TIMEZONE true
ENV CONTAINER_TIMEZONE Asia/Shanghai

ENV LANG C.UTF-8
ENTRYPOINT ["/bin/bash", "/run.sh"]
WORKDIR /app

CMD ["python3", "main.py"]
11 changes: 5 additions & 6 deletions build.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
build_from:
aarch64: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest
amd64: registry.cn-hangzhou.aliyuncs.com/arcw/sgcc_electricity:latest
labels:
org.opencontainers.image.title: "SGCC Electricity Add-on"
org.opencontainers.image.description: "State Grid Electric Data"
org.opencontainers.image.source: "https://github.com/ARC-MX/sgcc_electricity_new"
aarch64: registry.cn-hangzhou.aliyuncs.com/arcw/aarch64-sgcc_electricity:latest
amd64: registry.cn-hangzhou.aliyuncs.com/arcw/amd64-sgcc_electricity:latest
codenotary:
base_image: [email protected]
signer: [email protected]
23 changes: 12 additions & 11 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "SGCC Electricity New"
version: "latest"
slug: "sgcc_electricity_new"
description: "获取国网电费数据的插件(新版)"
name: "SGCC Electricity"
version: "v0.1.0"
slug: "sgcc_electricity"
description: "获取国网电费数据的插件"
url: "https://github.com/ARC-MX/sgcc_electricity_new"
arch:
- aarch64
Expand All @@ -10,12 +10,13 @@ host_network: true
startup: application
boot: auto
init: false
#image: "{arch}-sgcc_electricity_new"
# image: "registry.cn-hangzhou.aliyuncs.com/arcw/{arch}-addon-sgcc_electricity"
map:
- config:rw
options:
phone: ""
password: ""
password: ""
ignore_user_id: "xxxx,xxxx"
enable_database_storage: false
db_name: "homeassistant.db"
hass_url: "http://homeassistant.local:8123/"
Expand All @@ -29,11 +30,11 @@ options:
data_retention_days: 7
recharge_notify: false
balance: 5.0
pushplus_token: ""
pushplus_token: "xxxx,xxxx"
schema:
phone: str
password: password
IGNORE_USER_ID: "str?"
ignore_user_id: str
enable_database_storage: bool
db_name: str
hass_url: str
Expand All @@ -47,11 +48,11 @@ schema:
data_retention_days: int
recharge_notify: bool
balance: float
pushplus_token: "str?"
pushplus_token: str
environment:
PHONE_NUMBER: "${phone}"
PASSWORD: "${password}"
IGNORE_USER_ID: "${IGNORE_USER_ID}"
IGNORE_USER_ID: "${ignore_user_id}"
ENABLE_DATABASE_STORAGE: "${enable_database_storage}"
DB_NAME: "${db_name}"
HASS_URL: "${hass_url}"
Expand All @@ -63,6 +64,6 @@ environment:
RETRY_WAIT_TIME_OFFSET_UNIT: "${retry_wait_time_offset_unit}"
LOG_LEVE: "${log_level}"
DATA_RETENTION_DAYS: "${data_retention_days}"
RECHARGE_NOTIFY: "${IGNORE_USER_ID}"
RECHARGE_NOTIFY: "${recharge_notify}"
BALANCE: "${balance}"
PUSHPLUS_TOKEN: "${pushplus_token}"
4 changes: 2 additions & 2 deletions repository.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
name: sgcc_electricity_new add-on repository
name: sgcc_electricity add-on repository
url: 'https://github.com/ARC-MX/sgcc_electricity_new'
maintainer: sgcc_electricity_new
maintainer: sgcc_electricity
51 changes: 0 additions & 51 deletions run.sh

This file was deleted.

0 comments on commit 9b15269

Please sign in to comment.