diff --git a/.forgejo/actions/push-status-to-discord/action.yml b/.forgejo/actions/push-status-to-discord/action.yml deleted file mode 100644 index c514aa8..0000000 --- a/.forgejo/actions/push-status-to-discord/action.yml +++ /dev/null @@ -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 diff --git a/.forgejo/actions/push-status-to-discord/main.py b/.forgejo/actions/push-status-to-discord/main.py deleted file mode 100644 index f32a97b..0000000 --- a/.forgejo/actions/push-status-to-discord/main.py +++ /dev/null @@ -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"]) diff --git a/.forgejo/actions/push-status-to-discord/requirements.txt b/.forgejo/actions/push-status-to-discord/requirements.txt deleted file mode 100644 index 610f441..0000000 --- a/.forgejo/actions/push-status-to-discord/requirements.txt +++ /dev/null @@ -1 +0,0 @@ -httpx==0.27 diff --git a/.forgejo/workflows/ci.yml b/.forgejo/workflows/ci.yml index edaa85d..1dc9180 100644 --- a/.forgejo/workflows/ci.yml +++ b/.forgejo/workflows/ci.yml @@ -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 }}