From 1875b7e24ef02950d86ffc2679006b4cdb0f38a4 Mon Sep 17 00:00:00 2001 From: Romuald Brillout Date: Sat, 6 Apr 2024 13:01:45 +0200 Subject: [PATCH] add GitHub workflows --- .github/workflows/discord.yml | 34 ++++++++++++++++++++++++++++++++ .github/workflows/formatting.yml | 12 +++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/workflows/discord.yml create mode 100644 .github/workflows/formatting.yml diff --git a/.github/workflows/discord.yml b/.github/workflows/discord.yml new file mode 100644 index 00000000..b7c4a45c --- /dev/null +++ b/.github/workflows/discord.yml @@ -0,0 +1,34 @@ +name: Discord Notification + +on: + workflow_run: + workflows: ['CI', 'Docs'] + types: [completed] + +jobs: + notify: + # if: ${{ github.event.workflow_run.conclusion == 'failure' }} + runs-on: ubuntu-latest + steps: + - name: Push the notification using Discord webhook + env: + # 🟢 has poor compatibility: https://www.unicompat.com/1F7E2 + CI_STATUS: ${{ github.event.workflow_run.conclusion == 'success' && '✅' || github.event.workflow_run.conclusion == 'failure' && '🔴' || github.event.workflow_run.conclusion }} + REPO_NAME: ${{ github.event.repository.name }} + GIT_BRANCH: ${{ github.event.workflow_run.head_branch }} + WORKFLOW_NAME: ${{ github.event.workflow_run.name }} + WORKFLOW_URL: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.html_url || '' }} + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} + # Playground: https://gist.github.com/brillout/da1ab713bda6e3c0d2ad909c1a4e80f2 + run: | + curl \ + -i \ + -H "Accept: application/json" \ + -H "Content-Type:application/json" \ + -X POST \ + --data "{\"content\":\"$CI_STATUS $REPO_NAME $WORKFLOW_NAME $GIT_BRANCH $WORKFLOW_URL\",\"username\":\"GitHub\",\"avatar_url\":\"https://i.imgur.com/OOtUMJD.png\"}" \ + $DISCORD_WEBHOOK + - name: Debug/inspect + env: + EVENT: ${{ toJSON( github.event ) }} + run: echo $EVENT diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml new file mode 100644 index 00000000..ee9f5657 --- /dev/null +++ b/.github/workflows/formatting.yml @@ -0,0 +1,12 @@ +name: 'Check formatting' +on: + push: +jobs: + check_formatting: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v3 + - run: pnpm install + - run: pnpm run format:check +