From f80e18d04f8a4d78aae87ce0d24e34b6ad84e78e Mon Sep 17 00:00:00 2001 From: yamaks2306 <43762947+yamaks2306@users.noreply.github.com> Date: Wed, 23 Nov 2022 21:29:10 +0300 Subject: [PATCH] test composite --- .gitignore | 3 ++- action.yaml | 20 ++++++++++++++++++-- main.py | 30 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/.gitignore b/.gitignore index 34b9ba1..5a891d8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ -.testenvs \ No newline at end of file +.testenvs +.vscode/ \ No newline at end of file diff --git a/action.yaml b/action.yaml index 8ac58a2..4669d7a 100644 --- a/action.yaml +++ b/action.yaml @@ -29,8 +29,24 @@ inputs: required: false runs: - using: 'docker' - image: 'Dockerfile' + using: 'composite' + steps: + + - shell: bash + run: python3 ${{ github.action_path }}/main.py + env: + CHAT_ID: ${{ inputs.chat_id }} + TOKEN: ${{ inputs.token }} + STATUS: ${{ inputs.status }} + COMMIT_MESSAGE: ${{ inputs.commit_message }} + DOCKER_TAGS: ${{ inputs.docker_tags }} + INCLUDE_COMMIT_INFO: ${{ inputs.include_commit_info }} + MESSAGE: ${{ inputs.message }} + WORKFLOW: ${{ github.workflow }} + REPOSITORY: ${{ github.repository }} + SHA: ${{ github.sha }} + ACTOR: ${{ github.actor }} + TAG: ${{ github.ref }} branding: icon: 'send' diff --git a/main.py b/main.py index 93621c1..535d4b4 100644 --- a/main.py +++ b/main.py @@ -2,23 +2,23 @@ import os from message import Message from environments import Environment -chat_id = os.getenv('INPUT_CHAT_ID') -if chat_id == "": +chat_id = os.getenv('CHAT_ID') +if chat_id == "" or chat_id is None: raise SystemExit('Variable chat_id is required. Exit.') -token = os.getenv('INPUT_TOKEN') -if token == "": - raise SystemExit('Variable chat_id is required. Exit.') -status = os.getenv('INPUT_STATUS') -commit = os.getenv('INPUT_COMMIT_MESSAGE') -include_commit_info = os.getenv('INPUT_INCLUDE_COMMIT_INFO') -docker_tags = os.getenv('INPUT_DOCKER_TAGS') -custom_message = os.getenv('INPUT_MESSAGE') +token = os.getenv('TOKEN') +if token == "" or token is None: + raise SystemExit('Variable token is required. Exit.') +status = os.getenv('STATUS') +commit = os.getenv('COMMIT_MESSAGE') +include_commit_info = os.getenv('INCLUDE_COMMIT_INFO') +docker_tags = os.getenv('DOCKER_TAGS') +custom_message = os.getenv('MESSAGE') #GitHub environment variables -github_workflow = os.getenv('GITHUB_WORKFLOW') -github_repository = os.getenv('GITHUB_REPOSITORY') -github_sha = os.getenv('GITHUB_SHA') -github_actor = os.getenv('GITHUB_ACTOR') -tag = os.getenv('GITHUB_REF') +github_workflow = os.getenv('WORKFLOW') +github_repository = os.getenv('REPOSITORY') +github_sha = os.getenv('SHA') +github_actor = os.getenv('ACTOR') +tag = os.getenv('TAG') envs = Environment( chat_id,