name: Discord Notification on: workflow_call: inputs: release_tag: required: true type: string discord_title: required: true type: string discord_color: required: true type: number discord_footer: required: true type: string secrets: DISCORD_WEBHOOK: required: true GH_TOKEN: required: true jobs: notify-discord: runs-on: ubuntu-latest steps: - name: Send Discord Notification env: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} GH_TOKEN: ${{ secrets.GH_TOKEN }} run: | RELEASE_INFO=$(gh release view "${{ inputs.release_tag }}" -R ${{ github.repository }} --json name,url,body,author) RELEASE_TITLE=$(echo "$RELEASE_INFO" | jq -r .name) if [ -z "$RELEASE_TITLE" ] || [ "$RELEASE_TITLE" = "null" ]; then RELEASE_TITLE="${{ inputs.release_tag }}"; fi RELEASE_URL=$(echo "$RELEASE_INFO" | jq -r .url) RELEASE_BODY=$(echo "$RELEASE_INFO" | jq -r .body) AUTHOR_NAME="Portabase" AUTHOR_ICON="https://github.com/Portabase.png" PAYLOAD=$(jq -n \ --arg title "$RELEASE_TITLE" \ --arg description "$RELEASE_BODY" \ --arg url "$RELEASE_URL" \ --arg author "$AUTHOR_NAME" \ --arg icon "$AUTHOR_ICON" \ --arg discord_title "${{ inputs.discord_title }}" \ --arg discord_footer "${{ inputs.discord_footer }}" \ --argjson discord_color ${{ inputs.discord_color }} \ '{ content: $discord_title, embeds: [{ title: $title, url: $url, description: $description, color: $discord_color, author: { name: $author, icon_url: $icon }, footer: { text: $discord_footer } }] }' ) curl -H "Content-Type: application/json" \ -d "$PAYLOAD" \ "$DISCORD_WEBHOOK"