-
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 ac93e14
Showing
4 changed files
with
54 additions
and
40 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,16 +1,18 @@ | ||
--- | ||
name: CI | ||
|
||
on: push | ||
|
||
jobs: | ||
run-linters: | ||
runs-on: ubuntu-latest | ||
container: python:3.12-alpine | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install shellcheck | ||
run: sudo apt update && sudo apt install shellcheck --yes | ||
|
||
- name: Run shellcheck | ||
run: shellcheck entrypoint.sh | ||
- name: Run linter and formatter with ruff | ||
run: | | ||
pip install ruff | ||
ruff format --check . | ||
ruff check --output-format github . |
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,43 @@ | ||
#!/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 | ||
# remove token because it will be send in headers | ||
url = uri.geturl().replace(f"{token}@", "") | ||
|
||
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() |