fix: check if message_id is truthy instead of None before using it

This commit is contained in:
Marc 2024-07-24 19:50:23 -04:00
parent 5910ced095
commit 0b65351c67
Signed by: marc
GPG key ID: 048E042F22B5DC79
3 changed files with 10 additions and 9 deletions

View file

@ -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"]

View file

@ -1,3 +0,0 @@
#!/bin/bash
python ./main.py "$@"

View file

@ -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")