Try using the slackapi/slack GitHub action #9
This file contains 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: Build | |
on: | |
push: | |
workflow_dispatch: | |
schedule: | |
# Once week 06:18 on Saturday | |
- cron: '18 6 * * Sat' | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: pe-terminal-'${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
build: | |
runs-on: ["self-hosted", "client"] | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v4 | |
- name: Set up golang | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.20' | |
- name: Golang version | |
run: go version | |
- name: go build | |
run: go build ./... | |
- name: Run make.sh test (go vet + go test) | |
run: ./make.sh test | |
- name: Send build status to Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
# For posting a rich message using Block Kit | |
channel: '#testing_builds' | |
payload: | | |
{ | |
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}", | |
"blocks": [ | |
{ | |
"type": "section", | |
"text": { | |
"type": "mrkdwn", | |
"text": "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}" | |
} | |
} | |
] | |
} | |