-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change entrypoint to use python script instead of bash
- Loading branch information
1 parent
8e4a253
commit ebf3b48
Showing
3 changed files
with
45 additions
and
34 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 |
---|---|---|
@@ -1,7 +1,5 @@ | ||
FROM alpine:3.19 | ||
FROM python:3.12-alpine | ||
|
||
RUN apk --update add curl bash | ||
COPY main.py /main.py | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] | ||
ENTRYPOINT ["/main.py"] |
This file was deleted.
Oops, something went wrong.
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,42 @@ | ||
#!/usr/bin/env python | ||
|
||
import os | ||
import sys | ||
from urllib import parse | ||
from urllib.error import HTTPError | ||
from urllib.parse import urlparse | ||
from urllib.request import Request, urlopen | ||
|
||
PROJECT = os.environ.get("INPUT_PROJECT") | ||
ENVIRONMENT = os.environ.get("INPUT_ENVIRONMENT") | ||
IMAGE_VERSION = os.environ.get("INPUT_IMAGE_VERSION") | ||
GITHUB_USERNAME = os.environ.get("GITHUB_ACTOR") | ||
URL = os.environ.get("INPUT_URL") | ||
|
||
|
||
def main(): | ||
uri = urlparse(URL) | ||
token = uri.username | ||
url = f"{uri.scheme}://{uri.hostname}:{uri.port}{uri.path}" | ||
|
||
payload = { | ||
"environment_type": ENVIRONMENT, | ||
"project_name": PROJECT, | ||
"image_version": IMAGE_VERSION, | ||
"github_username": GITHUB_USERNAME, | ||
} | ||
data = parse.urlencode(payload).encode() | ||
request = Request(url, headers={"X-Api-Key": str(token)}, data=data) | ||
try: | ||
with urlopen(request) as response: | ||
if response.status == 201: | ||
sys.stdout.write( | ||
f"Deployment created with uid: {response.read().decode()}\n" | ||
) | ||
except HTTPError as error: | ||
sys.stderr.write(f"HTTP Error: {error.reason} {error.read().decode()}") | ||
sys.exit(1) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |