chore: extract status-post into own repo
This commit is contained in:
parent
35de43427b
commit
fabbf51317
4 changed files with 2 additions and 95 deletions
|
@ -1,48 +0,0 @@
|
|||
inputs:
|
||||
webhook-url:
|
||||
description: "Discord webhook URL events should be sent to."
|
||||
required: true
|
||||
project-name:
|
||||
description: "Project name."
|
||||
required: true
|
||||
status:
|
||||
description: "Status to report."
|
||||
required: true
|
||||
message-id:
|
||||
description: "Message ID to edit."
|
||||
init:
|
||||
description: "Marks the first status push, prevents pulling context."
|
||||
|
||||
|
||||
outputs:
|
||||
message-id:
|
||||
description: "ID of the message that was posted, for editing purposes in further calls."
|
||||
value: ${{ steps.post-message.outputs.message-id }}
|
||||
|
||||
runs:
|
||||
using: "composite"
|
||||
steps:
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
- uses: actions/download-artifact@v3
|
||||
if: ${{ !inputs.init }}
|
||||
with:
|
||||
name: "${{ github.sha }}-${{github.run_number}}-discord-context.zip"
|
||||
path: /tmp
|
||||
- id: set-context
|
||||
run: |
|
||||
echo "message-id=$(cat /tmp/discord-context)" >> $GITHUB_OUTPUT
|
||||
- name: Install dependencies
|
||||
if: ${{ always() }}
|
||||
run: pip install -r ./.forgejo/actions/push-status-to-discord/requirements.txt
|
||||
- id: post-message
|
||||
run: |
|
||||
echo "$(python ./.forgejo/actions/push-status-to-discord/main.py ${{ inputs.webhook-url }} ${{ inputs.project-name }} ${{ inputs.status }} ${{ steps.set-context.outputs.message-id }})" >> discord-context
|
||||
- uses: actions/upload-artifact@v3
|
||||
with:
|
||||
path: ./discord-context
|
||||
name: "${{ github.sha }}-${{ github.run_number }}-discord-context.zip"
|
||||
retention-days: 1
|
||||
overwrite: true
|
|
@ -1,44 +0,0 @@
|
|||
import sys
|
||||
import typing
|
||||
|
||||
import httpx
|
||||
|
||||
COLORS = {
|
||||
"failure": 0xCB2431,
|
||||
"success": 0x28A745,
|
||||
}
|
||||
|
||||
|
||||
class EmbedField(typing.TypedDict):
|
||||
name: str
|
||||
value: str
|
||||
inline: bool
|
||||
|
||||
|
||||
class Embed(typing.TypedDict):
|
||||
color: str
|
||||
title: str
|
||||
fields: list[EmbedField]
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
webhook_url, project_name, status = sys.argv[1:4]
|
||||
message_id = None
|
||||
if len(sys.argv) > 4:
|
||||
message_id = sys.argv[4]
|
||||
|
||||
embed_data = Embed(
|
||||
color=COLORS["success"],
|
||||
title=f"{project_name}: build #",
|
||||
fields=[EmbedField(name="Status", value=status, inline=True)],
|
||||
)
|
||||
|
||||
if message_id:
|
||||
response = httpx.patch(
|
||||
f"{webhook_url}/messages/{message_id}?wait=true",
|
||||
json={"embeds": [embed_data]},
|
||||
)
|
||||
else:
|
||||
response = httpx.post(f"{webhook_url}?wait=true", json={"embeds": [embed_data]})
|
||||
|
||||
print(response.json()["id"])
|
|
@ -1 +0,0 @@
|
|||
httpx==0.27
|
|
@ -6,7 +6,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.forgejo/actions/push-status-to-discord
|
||||
- uses: https://forge.karnov.club/marc/push-status-to-discord-action@main
|
||||
id: post-status
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
|
@ -29,7 +29,7 @@ jobs:
|
|||
if: always()
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: ./.forgejo/actions/push-status-to-discord
|
||||
- uses: https://forge.karnov.club/marc/push-status-to-discord-action@main
|
||||
with:
|
||||
webhook-url: ${{ secrets.DISCORD_WEBHOOK_URL }}
|
||||
project-name: ${{ github.repository }}
|
||||
|
|
Loading…
Reference in a new issue