コード例 #1
0
def main():
    requests.get('https://httpbin.org/get?code=0')
    username = core.get_input('username')
    res = f"Hello {username}"
    core.info("test")
    core.set_command_echo(True)
    core.set_output('res', res)
    tz = timezone(timedelta(hours=+8))
    time = datetime.now(tz).strftime('%Y-%m-%d %H:%M:%S')
    print(f"::set-output name=time::{time}")
    context = Context()
    print(context)
    print(context.payload)
コード例 #2
0
ファイル: test.py プロジェクト: yanglbme/v2ex-action
import os

from actions_toolkit import core

from app import log
from app.action import Action

os.environ[
    'INPUT_WEBHOOK'] = 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=01a56312-d0cb-dffx-8f15-8821d8f3a9e2'
os.environ['INPUT_COUNT'] = '10'

try:
    hook = core.get_input('webhook', required=True)
    secret = core.get_input('secret')
    count = int(core.get_input('count') or 8)

    action = Action(hook, secret, count)
    action.run()
except Exception as e:
    log.set_failed(str(e))
コード例 #3
0
from actions_toolkit import core

from app.action import Action

if __name__ == '__main__':
    username = core.get_input('gitee-username')
    password = core.get_input('gitee-password')
    repo = core.get_input('gitee-repo')
    branch = core.get_input('branch', required=False)
    directory = core.get_input('directory', required=False)
    https = core.get_input('https', required=False)
    action = Action(username, password, repo, branch, directory, https)
    try:
        action.run()
        core.info('Rebuild Gitee Pages successfully.')
    except Exception as e:
        core.set_failed(str(e))
コード例 #4
0
ファイル: main.py プロジェクト: fakegit/v2ex-action
                                verify=False)
            match = re.compile(
                '<span class="item_hot_topic_title">(.*?)</span>', re.DOTALL)
            for item in match.findall(resp.text):
                detail_url = 'https://v2ex.com' + re.search(
                    '<a href="(.*?)">', item.strip()).group(1)
                title = re.search('">(.*?)</a>', item.strip()).group(1)
                content = f'> - [{title}]({detail_url})\n'
                contents.append(content)
            return contents
        except Exception as e:
            core.set_failed(f'something error occurred, message: {e}')

    def run(self):
        contents = Action.get_v2ex_hot_topics()
        self.contents = contents[:self.count]
        if 'weixin' in self.hook:
            self.wx()
        elif 'dingtalk' in self.hook:
            self.ding()
        core.set_output('result', self.res)


if __name__ == '__main__':
    input_hook = core.get_input('webhook')
    input_secret = core.get_input('secret', required=False)
    count_str = core.get_input('count')
    input_count = int(count_str) if count_str else 8
    action = Action(input_hook, input_secret, input_count)
    action.run()