Skip to content

Instantly share code, notes, and snippets.

@parjun8840
Created January 15, 2023 12:48
Show Gist options
  • Save parjun8840/5e7fb65df11627bd2a90bf198403accd to your computer and use it in GitHub Desktop.
Save parjun8840/5e7fb65df11627bd2a90bf198403accd to your computer and use it in GitHub Desktop.
go test, build , run , upload artifacts , slack msg
on: [push]
name: go build
jobs:
build:
strategy:
matrix:
go-version: [1.18.x, 1.19.x]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
outputs:
job-status: ${{ job.status }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- run: go env -w GO111MODULE=auto
- run: go test -v
- run: go test -cover -coverprofile=c.out
- run: go tool cover -html=c.out -o coverage.html
- run: go build name.go
- run: go run name.go
- uses: actions/upload-artifact@v3
with:
name: coverage-report
path: |
coverage.html
name
slack_msg_send:
needs: build
runs-on: ubuntu-latest
steps:
- name: Post to a Slack channel
id: slack
uses: slackapi/slack-github-action@v1.23.0
with:
# Slack channel id, channel name, or user id to post message.
# See also: https://api.slack.com/methods/chat.postMessage#channels
# For posting a rich message using Block Kit
payload: |
{
"text": "GitHub Action build completed:\n Status of Job: ${{ needs.build.outputs.job-status }} \n URL of the commit: ${{ github.event.pull_request.html_url || github.event.head_commit.url }}"}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment