ci: adapt workflows to run for syn/master branch #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Binary | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
# - master | |
- 'syn/master' | |
#pull_request: | |
# branches: [ master ] | |
env: | |
IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/bivac | |
DOCKER_CLI_EXPERIMENTAL: enabled | |
jobs: | |
linting: | |
name: Linting | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Latest Docker | |
run: | | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.20 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Run Go Vet | |
run: make vet | |
- name: Lint code | |
run: make lint | |
tests: | |
name: Unit testing | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Latest Docker | |
run: | | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.20 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- name: Run unit tests | |
run: make test | |
- name: Send coverage | |
uses: shogo82148/actions-goveralls@v1 | |
with: | |
path-to-profile: coverage | |
build-binary: | |
name: Build Binary | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Latest Docker | |
run: | | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.20 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Build binary | |
run: make bivac | |
build-docker-image: | |
name: Build Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install Latest Docker | |
run: | | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.20 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Build docker image | |
run: docker build --build-arg GO_VERSION=1.20 --build-arg GOOS=linux --build-arg GOARCH=amd64 . | |
publish-docker-image-latest: | |
name: Publish docker image tagged latest | |
runs-on: ubuntu-latest | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} | |
steps: | |
- name: Install Latest Docker | |
run: | | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
sudo apt-get update | |
sudo apt-get install docker-ce | |
- name: Check out the repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Login to Github Registry | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.CR_PAT }} | |
- name: Build and push docker images | |
run: | | |
IMAGE_NAME=${{ env.IMAGE_NAME }} IMAGE_VERSION=latest KEEP_IMAGES=yes make docker-images |