Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 2.4.0 to 2.6.1. - [Release notes](https://github.com/docker/build-push-action/releases) - [Commits](https://github.com/docker/build-push-action/compare/v2.4.0...v2.6.1) --- updated-dependencies: - dependency-name: docker/build-push-action dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
101 lines
3.0 KiB
YAML
101 lines
3.0 KiB
YAML
name: CI
|
|
on:
|
|
push:
|
|
paths:
|
|
- .github/workflows/ci.yml
|
|
- cmd/**
|
|
- internal/**
|
|
- pkg/**
|
|
- .dockerignore
|
|
- .golangci.yml
|
|
- Dockerfile
|
|
- go.mod
|
|
- go.sum
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
DOCKER_BUILDKIT: "1"
|
|
steps:
|
|
- uses: actions/checkout@v2.3.4
|
|
|
|
- name: Linting
|
|
run: docker build --target lint .
|
|
|
|
- name: Go mod tidy check
|
|
run: docker build --target tidy .
|
|
|
|
- name: Build test image
|
|
run: docker build --target test -t test-container .
|
|
|
|
- name: Run tests in test container
|
|
run: |
|
|
touch coverage.txt
|
|
docker run --rm \
|
|
-v "$(pwd)/coverage.txt:/tmp/gobuild/coverage.txt" \
|
|
test-container
|
|
|
|
- name: Code security analysis
|
|
uses: snyk/actions/golang@master
|
|
env:
|
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
|
|
- name: Build final image
|
|
run: docker build -t final-image .
|
|
|
|
- name: Image security analysis
|
|
uses: snyk/actions/docker@master
|
|
env:
|
|
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
|
|
with:
|
|
image: final-image
|
|
|
|
publish:
|
|
needs: [verify]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v2.3.4
|
|
|
|
- uses: docker/setup-qemu-action@v1
|
|
- uses: docker/setup-buildx-action@v1
|
|
|
|
- uses: docker/login-action@v1
|
|
with:
|
|
username: qmcgaw
|
|
password: ${{ secrets.DOCKERHUB_PASSWORD }}
|
|
|
|
- name: Set variables
|
|
id: vars
|
|
env:
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
run: |
|
|
BRANCH=${GITHUB_REF#refs/heads/}
|
|
TAG=${GITHUB_REF#refs/tags/}
|
|
echo ::set-output name=commit::$(git rev-parse --short HEAD)
|
|
echo ::set-output name=build_date::$(date -u +%Y-%m-%dT%H:%M:%SZ)
|
|
if [ "$TAG" != "$GITHUB_REF" ]; then
|
|
echo ::set-output name=version::$TAG
|
|
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/ppc64le
|
|
elif [ "$BRANCH" = "master" ]; then
|
|
echo ::set-output name=version::latest
|
|
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/ppc64le
|
|
else
|
|
echo ::set-output name=version::$BRANCH
|
|
echo ::set-output name=platforms::linux/amd64,linux/386,linux/arm64,linux/arm/v6,linux/arm/v7,linux/ppc64le
|
|
fi
|
|
|
|
- name: Build and push final image
|
|
uses: docker/build-push-action@v2.6.1
|
|
with:
|
|
platforms: ${{ steps.vars.outputs.platforms }}
|
|
build-args: |
|
|
BUILD_DATE=${{ steps.vars.outputs.build_date }}
|
|
COMMIT=${{ steps.vars.outputs.commit }}
|
|
VERSION=${{ steps.vars.outputs.version }}
|
|
ALLTARGETPLATFORMS=${{ steps.vars.outputs.platforms }}
|
|
tags: |
|
|
qmcgaw/gluetun:${{ steps.vars.outputs.version }}
|
|
qmcgaw/private-internet-access:${{ steps.vars.outputs.version }}
|
|
push: true
|