-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: create docker exporter | ||
on: | ||
workflow_dispatch: | ||
branches: | ||
- master | ||
jobs: | ||
create-docker-bridge: | ||
name: create docker Domotik Exporter | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: docker/setup-qemu-action@v2 | ||
- uses: docker/setup-buildx-action@v2 | ||
- uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- uses: docker/build-push-action@v2 | ||
with: | ||
context: '{{defaultContext}}:exporter' | ||
push: true | ||
platforms: linux/amd64,linux/arm64 | ||
tags: ghcr.io/sylvek/domotik-exporter:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FROM ruby:slim | ||
RUN gem install sqlite3 httparty | ||
COPY main.rb /main.rb | ||
CMD ["ruby", "main.rb"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require 'sqlite3' | ||
require 'httparty' | ||
|
||
entrypoint = ENV['ENTRYPOINT'] | ||
db = SQLite3::Database.new ENV['DATABASE'] | ||
|
||
db.execute("SELECT ts,value FROM data WHERE name='daily_power_consumption' ORDER BY ts DESC LIMIT 1") do |row| | ||
title = "#{row[1].to_i/1000.0} kW.h" | ||
response = HTTParty.get("#{entrypoint}?title=#{title}×tamp=#{row[0]}") | ||
puts response.body | ||
end |