fix: check if message_id is truthy instead of None before using it
This commit is contained in:
parent
5910ced095
commit
0b65351c67
3 changed files with 10 additions and 9 deletions
|
@ -6,7 +6,8 @@ COPY ./requirements.txt ./requirements.txt
|
||||||
|
|
||||||
RUN pip install --upgrade pip && pip install -r ./requirements.txt
|
RUN pip install --upgrade pip && pip install -r ./requirements.txt
|
||||||
|
|
||||||
COPY ./main.py ./main.py
|
WORKDIR /action
|
||||||
COPY ./entrypoint.sh ./entrypoint.sh
|
|
||||||
|
|
||||||
ENTRYPOINT ["./entrypoint.sh"]
|
COPY ./main.py ./main.py
|
||||||
|
|
||||||
|
ENTRYPOINT ["python", "/action/main.py"]
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
python ./main.py "$@"
|
|
9
main.py
9
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()
|
previous_message_data = httpx.get(f"{webhook_url}/messages/{message_id}").json()
|
||||||
|
|
||||||
response = httpx.patch(
|
response = httpx.patch(
|
||||||
|
@ -82,7 +82,10 @@ if __name__ == "__main__":
|
||||||
response = httpx.post(f"{webhook_url}?wait=true", json={"embeds": [embed_data]})
|
response = httpx.post(f"{webhook_url}?wait=true", json={"embeds": [embed_data]})
|
||||||
message_id = response.json()["id"]
|
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:
|
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")
|
||||||
|
|
Loading…
Reference in a new issue