Skip to content

Commit

Permalink
Combine the test and docker workflows (#4)
Browse files Browse the repository at this point in the history
* Combine the test and docker workflows

* Fixed the dependency name in the cicd workflow
  • Loading branch information
idgenchev authored Apr 10, 2021
1 parent 05f7db0 commit cfda474
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 65 deletions.
55 changes: 33 additions & 22 deletions .github/workflows/docker.yaml → .github/workflows/cicd.yaml
Original file line number Diff line number Diff line change
@@ -1,27 +1,47 @@
name: Build and push docker images
name: CI/CD

on:
push:
branches:
- 'main'
tags:
- 'v*.*.*'
- 'v*.*'

workflow_run:
workflows:
- 'Test'
pull_request:
branches:
- 'main'
tags:
- 'v*.*.*'
- 'v*.*'
types:
- completed

jobs:
docker:
if: ${{ github.event.workflow_run.conclusion == 'success' }}

lint-and-test:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16

- name: Install dependencies
run: go get -u golang.org/x/lint/golint

- name: Lint
run: golint -set_exit_status ./...

- name: Check gofmt
run: ./scripts/gofmt-check.sh

- name: Vet
run: go vet ./...

- name: Test
run: go test -v ./...

build-and-push-docker-images:
needs: lint-and-test
if: ${{ github.event_name != 'pull_request' }}

runs-on: ubuntu-latest

Expand All @@ -38,12 +58,8 @@ jobs:
flavor: |
latest=true
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Docker meta for the init container
id: initmeta
Expand All @@ -54,12 +70,8 @@ jobs:
flavor: |
latest=true
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
Expand All @@ -68,7 +80,6 @@ jobs:
uses: docker/setup-buildx-action@v1

- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
41 changes: 0 additions & 41 deletions .github/workflows/test.yaml

This file was deleted.

3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
![Tests](https://github.com/idgenchev/namespace-node-affinity/actions/workflows/test.yaml/badge.svg?branch=main)
![Build and push docker images](https://github.com/idgenchev/namespace-node-affinity/actions/workflows/docker.yaml/badge.svg?branch=main)
![CI/CD](https://github.com/idgenchev/namespace-node-affinity/actions/workflows/cicd.yaml/badge.svg?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/idgenchev/namespace-node-affinity)](https://goreportcard.com/report/github.com/idgenchev/namespace-node-affinity)

# Namespace Node Affinity
Expand Down

0 comments on commit cfda474

Please sign in to comment.