Skip to content

Commit

Permalink
Build/go.yml (#3)
Browse files Browse the repository at this point in the history
* build: modify

* build: modify

* Update go.yml

* Update go.yml

* Update go.yml

* Update go.yml
  • Loading branch information
noobj authored Sep 20, 2022
1 parent 8d71068 commit 5c10f34
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ name: Go

on:
push:
branches: [ "main" ]
branches: [ "**" ]
pull_request:
branches: [ "main" ]

jobs:

test:
runs-on: ubuntu-latest
outputs:
flag: ${{ steps.set-flag.outputs.flag }}
steps:
- uses: actions/checkout@v3

Expand Down Expand Up @@ -39,27 +41,40 @@ jobs:
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS }}
run: goveralls -coverprofile=coverprofile.out


- name: Set flag to failed
if: failure()
id: set-flag
run: echo "::set-output name=flag::true"
build:
runs-on: ubuntu-latest
outputs:
flag: ${{ steps.set-flag.outputs.flag }}
steps:
- uses: actions/checkout@v3

- name: Build
run: go build -v ./...

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.18

- name: Build
run: go build -v ./...

- name: Set flag to failed
if: failure()
id: set-flag
run: echo "::set-output name=flag::true"

push_notification_tg:
needs: [test, build]
needs:
- test
- build
runs-on: ubuntu-latest

if: always()
steps:
- name: send telegram message when failed
if: failure()
if: ${{needs.test.outputs.flag == 'true' || needs.build.outputs.flag == 'true' }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
Expand All @@ -70,7 +85,7 @@ jobs:
Commit : ${{ github.event.commits[0].message }}
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
- name: send telegram message when success
if: success()
if: ${{ !contains(needs.test.outputs.flag, 'true') && !contains(needs.build.outputs.flag, 'true') }}
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
Expand Down

0 comments on commit 5c10f34

Please sign in to comment.