From 0b65351c6759a3de08f3fc87e92ee6533add4dbd Mon Sep 17 00:00:00 2001 From: Marc Cataford Date: Wed, 24 Jul 2024 19:50:23 -0400 Subject: [PATCH] fix: check if message_id is truthy instead of None before using it --- Dockerfile | 7 ++++--- entrypoint.sh | 3 --- main.py | 9 ++++++--- 3 files changed, 10 insertions(+), 9 deletions(-) delete mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile index b1bfe25..3de807b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,8 @@ COPY ./requirements.txt ./requirements.txt RUN pip install --upgrade pip && pip install -r ./requirements.txt -COPY ./main.py ./main.py -COPY ./entrypoint.sh ./entrypoint.sh +WORKDIR /action -ENTRYPOINT ["./entrypoint.sh"] +COPY ./main.py ./main.py + +ENTRYPOINT ["python", "/action/main.py"] diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index 8cbe8a3..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -python ./main.py "$@" diff --git a/main.py b/main.py index a37df2f..a664bec 100644 --- a/main.py +++ b/main.py @@ -70,7 +70,7 @@ if __name__ == "__main__": ], ) - if message_id is not None: + if message_id: previous_message_data = httpx.get(f"{webhook_url}/messages/{message_id}").json() response = httpx.patch( @@ -82,7 +82,10 @@ if __name__ == "__main__": response = httpx.post(f"{webhook_url}?wait=true", json={"embeds": [embed_data]}) message_id = response.json()["id"] - outputs_path = os.environ.get("GITHUB_ENV") + outputs_path = os.environ.get("GITHUB_OUTPUT") + + if not outputs_path: + raise RuntimeError("Cannot write to outputs, no GITHUB_ENV set.") with open(outputs_path, "a", encoding="utf-8") as outputs_file: - outputs_file.write(f"message-id={message_id}") + outputs_file.write(f"message-id={message_id}\n")