Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ci/notify discussions release #643

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 61 additions & 21 deletions .github/workflows/notify-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,81 @@ on:
release:
types: [published]

workflow_dispatch:
inputs:
tag:
description: "Release tag (leave empty for last one)"

jobs:
notify-discord:
set-env:
runs-on: ubuntu-22.04
outputs:
tag: ${{ steps.set-env.outputs.tag }}
repo_name: ${{ steps.set-env.outputs.repo_name }}
steps:
- name: Notify Discord
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.DISCORD_WEBHOOK }}
method: "POST"
customHeaders: '{"Content-Type": "application/json"}'
data: |-
{
"avatar_url": "https://avatars.githubusercontent.com/u/98603954?v=4",
"username": "Bot Anik",
"content": "🚨 A new version of @${{ github.repository }} ${{ github.event.release.tag_name }} has been released! 🎉\n\n👉 Changelog: https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}\n👉 Official repo: https://github.com/${{ github.repository }}"
}
- name: Expose tag and repo_name
id: set-env
run: |
if [ -n "$INPUT_TAG" ]; then
TAG="$INPUT_TAG"
else
TAG=$(gh release view --json tagName -q '.tagName')
fi
echo "tag=$TAG" >> $GITHUB_OUTPUT

REPO_NAME=${GITHUB_REPOSITORY#${GITHUB_REPOSITORY_OWNER}/}
echo "repo_name=$REPO_NAME" >> $GITHUB_OUTPUT
env:
INPUT_TAG: ${{ github.event.inputs.tag }}

notify-github-discussion:
runs-on: ubuntu-22.04
needs: set-env
steps:
- name: Post announcement to GitHub Discussion
uses: abirismyname/create-discussion@v1
- name: Check out repository
uses: actions/checkout@v4

- name: Extract changelog for tag
run: |
{
echo 'CHANGELOG<<EOF'
gh release view ${{ needs.set-env.outputs.tag }} --json body -q '.body'
echo 'EOF'
} >> "$GITHUB_ENV"
env:
GH_TOKEN: ${{ secrets.OPS_TOKEN }}

- name: Create an announcement discussion for release
uses: abirismyname/[email protected]
with:
title: "🎉 ${{ github.repository }} ${{ github.event.release.tag_name }} has been released"
title: 🎉 ${{ needs.set-env.outputs.repo_name }} ${{ needs.set-env.outputs.tag }} released!
body: |
🎉 [${{ github.repository }}](https://github.com/${{ github.repository }}) ${{ github.event.release.tag_name }} has been released!
Hey frens! [${{ github.repository }}](https://github.com/${{ github.repository }}) `${{ needs.set-env.outputs.tag }}` just dropped! 🚀

Some fresh updates are here. Dive into the changelog and see what's cooking! 🔥

# Changelog

👉 Changelog: <https://github.com/${{ github.repository }}/releases/tag/${{ github.event.release.tag_name }}>
👉 Official repo: <https://github.com/${{ github.repository }}>
repository-id: "R_kgDOLsWt6A"
category-id: "DIC_kwDOLsWt6M4CemGO"
${{ env.CHANGELOG }}

# Resources

📄 Changelog: <https://github.com/${{ github.repository }}/releases/tag/${{ needs.set-env.outputs.tag }}>
🛠️ Official repo: <https://github.com/${{ github.repository }}>
💬 Vibe with us on Discord: <${{ env.DISCORD_URL }}>
🐦 Catch us on 𝕏: <${{ env.TWITTER_URL }}>
repository-id: ${{ env.REPOSITORY_ID }}
category-id: ${{ env.CATEGORY_ID }}
env:
GH_TOKEN: ${{ secrets.OPS_TOKEN }}
DISCORD_URL: ${{ vars.DISCORD_URL }}
TWITTER_URL: ${{ vars.TWITTER_URL }}
REPOSITORY_ID: ${{ vars.DISCUSSIONS_REPOSITORY_ID }}
CATEGORY_ID: ${{ vars.DISCUSSIONS_CATEGORY_ID }}

update-docs:
runs-on: ubuntu-22.04
if: github.event_name != 'workflow_dispatch'
steps:
- name: Update docs repository
uses: fjogeleit/http-request-action@v1
Expand All @@ -61,6 +100,7 @@ jobs:

update-schema:
runs-on: ubuntu-22.04
if: github.event_name != 'workflow_dispatch'
steps:
- name: Update schema repository
uses: fjogeleit/http-request-action@v1
Expand Down
Loading