evcc-io/.github/workflows/default.yml
Andreas Linde 5e776fc458
Prevent building twice when pushing to a PR (#2345)
Created PRs and commit pushes to PRs are all already handled by `pull_request`. Having `push` without limitations causes 2 build runs on every PR commit push.

Also the `push` scenario is only required for pushes (direct or merges) to the master branch.
2022-01-19 12:44:15 +01:00

103 lines
1.9 KiB
YAML

name: Default
on:
push:
branches:
- master
pull_request:
workflow_call:
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.16
id: go
- name: Set up Node
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: gofmt
run: |
gofmt -w -l $(find . -name '*.go')
- name: Install tools
run: make install
- name: Assets
run: make assets
- name: Porcelain
run: |
go mod tidy
test -z "$(git status --porcelain)" || (git status; git diff; false)
- name: Build
run: make build
- name: Lint
uses: golangci/golangci-lint-action@v2
with:
version: latest
skip-go-installation: true
skip-pkg-cache: true
skip-build-cache: true
- name: Test
run: make test
build-ui:
name: Build UI
runs-on: ubuntu-latest
steps:
- name: Cache NPM modules
uses: actions/cache@v2
with:
path: |
**/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Checkout
uses: actions/checkout@v2
- name: Install tools
run: make install-ui
- name: Build
run: make ui
- name: Lint
run: make lint-ui
- name: Test
run: make test-ui
- name: Porcelain
run: |
test -z "$(git status --porcelain)" || (git status; git diff; false)