adguard-exporter/.github/workflows/ci.yml

126 lines
2.9 KiB
YAML

name: Build/Push (master)
on:
push:
branches:
- 'master'
pull_request:
branches:
- '*'
jobs:
changes:
runs-on: ubuntu-latest
outputs:
go: ${{ steps.filter.outputs.go }}
charts: ${{ steps.filter.outputs.charts }}
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: filter
with:
token: ${{ secrets.GITHUB_TOKEN }}
filters: |
go:
- '**/*.go'
- 'go.mod'
- 'go.sum'
test:
runs-on: ubuntu-latest
needs: changes
if: |
(needs.changes.outputs.go == 'true')
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v1
with:
go-version: 1.15
- name: Install go dependencies
run: go get -t -v ./...
- name: Run go tests
run: go test -v -cover -race ./...
build-docker:
runs-on: ubuntu-latest
needs: [changes,test]
if: |
(needs.changes.outputs.go == 'true')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push docker image
id: docker_build
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
platforms: linux/386,linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
push: true
tags: ebrianne/adguard-exporter:latest
build:
runs-on: ubuntu-latest
needs: [changes,test]
if: |
(needs.changes.outputs.go == 'true')
strategy:
matrix:
include:
- os: linux
arch: 386
- os: linux
arch: amd64
- os: linux
arch: arm
- os: linux
arch: arm64
- os: darwin
arch: amd64
- os: freebsd
arch: 386
- os: freebsd
arch: amd64
- os: windows
arch: 386
extension: '.exe'
- os: windows
arch: amd64
extension: '.exe'
steps:
- name: Checkout
uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: 1.15
- name: Download go dependencies
run: go get -t -v ./...
- name: Install the needed vendors
run: GO111MODULE=on go mod vendor
- name: Create release (${{ matrix.os }}-${{ matrix.arch }})
run: CGO_ENABLED=0 GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -a -ldflags '-s -w' -o adguard_exporter-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.extension }} ./