edu_edfi_source v0.5.2 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Notify Slack on Latest Release | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| jobs: | |
| notify-slack: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Fetch latest published release | |
| id: get_release | |
| run: | | |
| echo "🔍 Getting latest published release..." | |
| curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| -H "Accept: application/vnd.github+json" \ | |
| https://api.github.com/repos/${{ github.repository }}/releases \ | |
| | jq '[.[] | select(.draft == false and .prerelease == false)][0]' > release.json | |
| echo "RELEASE_NAME<<EOF" >> $GITHUB_ENV | |
| jq -r .name release.json >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "RELEASE_URL<<EOF" >> $GITHUB_ENV | |
| jq -r .html_url release.json >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
| jq -r .body release.json >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Print resolved values (debug) | |
| run: | | |
| echo "RELEASE_NAME: $RELEASE_NAME" | |
| echo "RELEASE_URL: $RELEASE_URL" | |
| echo "RELEASE_BODY:" | |
| echo "$RELEASE_BODY" | |
| - name: Send release info to Slack | |
| run: | | |
| pip install slack-sdk markdown2slack | |
| python3 << 'EOF' | |
| import os | |
| from slack_sdk.webhook import WebhookClient | |
| from markdown2slack.app import Convert | |
| # Create converter instance | |
| converter = Convert() | |
| webhook = WebhookClient(os.environ['SLACK_WEBHOOK_URL']) | |
| # Convert markdown to Slack format | |
| slack_formatted = converter.markdown_to_slack_format(os.environ['RELEASE_BODY']) | |
| response = webhook.send( | |
| text=f"New release published: {os.environ['RELEASE_NAME']}", | |
| blocks=[ | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": f"*New EDU Release:* <{os.environ['RELEASE_URL']}|{os.environ['RELEASE_NAME']}>" | |
| } | |
| }, | |
| { | |
| "type": "divider" | |
| }, | |
| { | |
| "type": "section", | |
| "text": { | |
| "type": "mrkdwn", | |
| "text": slack_formatted | |
| } | |
| } | |
| ] | |
| ) | |
| print(f"Response: {response.status_code}") | |
| EOF | |
| env: | |
| RELEASE_NAME: ${{ env.RELEASE_NAME }} | |
| RELEASE_URL: ${{ env.RELEASE_URL }} | |
| RELEASE_BODY: ${{ env.RELEASE_BODY }} | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |