From e40548645b0a5f15eaa2d0856758d395d02f3b16 Mon Sep 17 00:00:00 2001 From: Tushar <30565750+tushar5526@users.noreply.github.com> Date: Mon, 25 Dec 2023 22:13:29 +0530 Subject: [PATCH] init --- .dockerignore | 27 +++++++++++++++++++ .github/workflows/test.yml | 19 +++++++++++++ .gitignore | 16 +++++++++++ .idea/.gitignore | 3 +++ .idea/inspectionProfiles/Project_Default.xml | 21 +++++++++++++++ .../inspectionProfiles/profiles_settings.xml | 6 +++++ .idea/misc.xml | 4 +++ .idea/modules.xml | 8 ++++++ .idea/sarthi.iml | 12 +++++++++ Dockerfile | 11 ++++++++ LICENSE | 8 ++++++ README.md | 11 ++++++++ action.yml | 23 ++++++++++++++++ actions/__init__.py | 0 actions/io.py | 23 ++++++++++++++++ main.py | 25 +++++++++++++++++ requirements.txt | 0 17 files changed, 217 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/test.yml create mode 100644 .gitignore create mode 100644 .idea/.gitignore create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/sarthi.iml create mode 100644 Dockerfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 action.yml create mode 100644 actions/__init__.py create mode 100644 actions/io.py create mode 100644 main.py create mode 100644 requirements.txt diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..a606a14 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,27 @@ +# Ignore all files and folders that start with a dot. +**/*. + +# Ignore all virtual envs' +venv/ + +# Ignore all Python bytecode files. +__pycache__/ + +# Ignore all temporary files. +*.tmp +*.swp + +# Ignore all build artifacts. +build/ +dist/ + +# Ignore all pyaction-related files. +README.md +CONTRIBUTING.md +CHANGELOG.md +LICENSE +Dockerfile +.env +.github/ + +.git/ diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..78c6ae0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: Testing + +on: + push: + branches: + - main + +jobs: + Test: + runs-on: ubuntu-latest + name: Testing the action + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Run action + uses: ./ + with: + name: 'John' diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..6d54f31 --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm +__pypackages__/ + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..0458410 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,21 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..4dafca0 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..84721b8 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/sarthi.iml b/.idea/sarthi.iml new file mode 100644 index 0000000..8a05c6e --- /dev/null +++ b/.idea/sarthi.iml @@ -0,0 +1,12 @@ + + + + + + + + + + \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..92e8c07 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +# setting the base-image to alpine +FROM python:3-slim + +# importing the action +COPY . /action + +# installing the requirements +RUN pip install -U pip -r /action/requirements.txt + +# running the main.py file +CMD [ "python", "/action/main.py" ] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..26441fd --- /dev/null +++ b/LICENSE @@ -0,0 +1,8 @@ +The MIT License (MIT) +Copyright (c) 2023, Tushar Gupta + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..e51ea0b --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +## Sarthi action-badge cookiecutter-pyaction + +Easy to setup Docker based empheral previews! + +### Usage +```yml +example usage.. +``` + +### License +This action is licensed under some specific terms. Check [here](LICENSE) for more information. diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..e1507c6 --- /dev/null +++ b/action.yml @@ -0,0 +1,23 @@ +name: Sarthi +description: Easy to setup Docker based empheral previews! +author: Tushar Gupta + +branding: + icon: check + color: blue + +runs: + using: docker + image: Dockerfile + +# == inputs and outputs == + +inputs: + name: + required: false + description: the person/thing you want to greet + default: World + +outputs: + phrase: + description: output variable diff --git a/actions/__init__.py b/actions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/actions/io.py b/actions/io.py new file mode 100644 index 0000000..a514c11 --- /dev/null +++ b/actions/io.py @@ -0,0 +1,23 @@ +import os +from typing import Dict + +BUFFER_PATH = os.environ["GITHUB_OUTPUT"] + + +def write_to_output(context: Dict[str, str]) -> None: + """writes the keys (as variables) and values (as values) to the output buffer + + Args: + context: variables and values + + Examples: + In your project, use this function like: + + >>> write_to_output({"name": "John", ...}) + + ``name`` will be the variable name and ``John`` is the value. + """ + + with open(BUFFER_PATH, "a") as _buffer: + for var, val in context.items(): + _buffer.write(f"{var}={val}\r\n") diff --git a/main.py b/main.py new file mode 100644 index 0000000..68ac9f2 --- /dev/null +++ b/main.py @@ -0,0 +1,25 @@ +import os +import sys +from typing import List + +from actions import io + + +def main(args: List[str]) -> None: + """main function + + Args: + args: STDIN arguments + """ + + # now you can access the inputs like: + # f"Hello {os.environ["INPUT_NAME"]}" + + # you can write to output like: + # io.write_to_output({var: val, ...}) + + pass + + +if __name__ == "__main__": + main(sys.argv[1:]) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e69de29