File tree Expand file tree Collapse file tree 6 files changed +68
-10
lines changed
Expand file tree Collapse file tree 6 files changed +68
-10
lines changed Original file line number Diff line number Diff line change 1+ venv /
2+ .git
3+ .github
4+ .gitignore
5+ .idea
Original file line number Diff line number Diff line change 1+ name : Docker
2+
3+ on :
4+ push :
5+ # Publish `master` as Docker `latest` image.
6+ branches :
7+ - master
8+
9+ # Publish `v1.2.3` tags as releases.
10+ tags :
11+ - v*
12+
13+ env :
14+ IMAGE_NAME : delitter
15+
16+ jobs :
17+ push :
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - uses : actions/checkout@v2
22+
23+ - name : Build an image with a tag
24+ run : docker build -t app .
25+
26+ - name : Log into the registry
27+ run : echo "${{ secrets.GITHUB_TOKEN }}" | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin
28+
29+ - name : Push the image
30+ run : |
31+ IMAGE_ID=docker.pkg.github.com/${{ github.repository }}/$IMAGE_NAME
32+ VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
33+ [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
34+ [ "$VERSION" == "master" ] && VERSION=latest
35+ docker tag app $IMAGE_ID:$VERSION
36+ docker push $IMAGE_ID:$VERSION
Original file line number Diff line number Diff line change 1+ FROM python:3.8.5-buster
2+ RUN mkdir /src
3+ COPY . /src
4+ WORKDIR /src
5+ RUN python3 -m pip install -r requirements.txt
6+
7+ ENTRYPOINT ["python3" , "main.py" ]
Original file line number Diff line number Diff line change @@ -48,10 +48,10 @@ def __init__(
4848 self .approve_rate = approve_rate
4949
5050
51- def create (file : TextIO ) -> DiscordSetting :
51+ def create (json_text : str ) -> DiscordSetting :
5252 """
5353 Jsonファイルから設定をパースしてDiscordSettingを生成する
54- :param file: Jsonファイルを参照しているIO 。
54+ :param json_text: Jsonで記述された設定 。
5555 :return: 生成されたDiscordSetting
5656 """
5757 json_type = Dict [str , Union [None , str , int ]]
@@ -60,7 +60,7 @@ def create(file: TextIO) -> DiscordSetting:
6060 with open ("static/scheme/discord_scheme.json" ) as f :
6161 scheme_json : json_type = json .load (f )
6262
63- raw_json : json_type = json .load ( file )
63+ raw_json : json_type = json .loads ( json_text )
6464 validate (raw_json , scheme_json )
6565
6666 raw_json .setdefault ("token" , None )
Original file line number Diff line number Diff line change @@ -36,10 +36,10 @@ def __init__(
3636 self .access_secret_token = access_token_secret
3737
3838
39- def create (file : TextIO ) -> TwitterSetting :
39+ def create (json_text : str ) -> TwitterSetting :
4040 """
4141 Jsonファイルから設定をパースしてTwitterSettingを生成する
42- :param file: Jsonファイルを参照しているIO 。
42+ :param json_text: Jsonで記述された設定 。
4343 :return: 生成されたTwitterSetting
4444 """
4545 json_type = Dict [str , Union [None , str , int ]]
@@ -48,7 +48,7 @@ def create(file: TextIO) -> TwitterSetting:
4848 with open ("static/scheme/twitter_scheme.json" ) as f :
4949 scheme_json : json_type = json .load (f )
5050
51- raw_json : json_type = json .load ( file )
51+ raw_json : json_type = json .loads ( json_text )
5252 validate (raw_json , scheme_json )
5353
5454 raw_json .setdefault ("token" , None )
Original file line number Diff line number Diff line change 33------------------------
44プログラムのエントリポイント。
55"""
6+ import base64
7+ import os
8+
69from lib .data .tweet_votes_record import TweetsVoteRecord
710from lib .discord .client import MainClient
811from lib .discord .op .command .command_register import CommandRegister
1518from lib .twitter .tweeter import Tweeter
1619
1720if __name__ == '__main__' :
18- with open ("settings/discord.json" ) as f :
19- discord_setting : discord .DiscordSetting = discord .create (f )
2021
21- with open ("settings/twitter-api.json" ) as f :
22- twitter_setting : twitter .TwitterSetting = twitter .create (f )
22+ if "DELITTER_DISCORD_SETTING_JSON_B64" not in os .environ :
23+ raise RuntimeError ("DELITTER_DISCORD_SETTING_JSON_B64 is not set!" )
24+
25+ if "DELITTER_TWITTER_SETTING_JSON_B64" not in os .environ :
26+ raise RuntimeError ("DELITTER_TWITTER_SETTING_JSON_B64 is not set!" )
27+
28+ raw_discord_setting = base64 .b64decode (os .environ ["DELITTER_DISCORD_SETTING_JSON_B64" ]).decode ("utf-8" )
29+ raw_twitter_setting = base64 .b64decode (os .environ ["DELITTER_TWITTER_SETTING_JSON_B64" ]).decode ("utf-8" )
30+
31+ discord_setting : discord .DiscordSetting = discord .create (raw_discord_setting )
32+ twitter_setting : twitter .TwitterSetting = twitter .create (raw_twitter_setting )
2333
2434 votes_record = TweetsVoteRecord ()
2535 command_register = CommandRegister (discord_setting )
You can’t perform that action at this time.
0 commit comments