Skip to content

Lab 8, bonus task

Lab 8, bonus task #7

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Go application
on:
push:
paths:
- .github/workflows/**
- app_go/**
permissions:
contents: read
jobs:
lint-test-snyk:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ["1.21", "1.22"]
defaults:
run:
working-directory: ./app_go
steps:
- uses: actions/checkout@v4
- name: Set up Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
#cache-dependency-path: app_go/go.sum
- name: Build
run: go build
- name: Lint with `go vet`
run: go vet
- name: Test with `go test`
run: |
go test
- name: Check for vulnerabilities with Snyk
uses: snyk/actions/golang@master
with:
args: app_go/
env:
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
docker-build-push:
needs: [ lint-test-snyk ]
runs-on: ubuntu-latest
steps:
- name: Cache Docker images
uses: ScribeMD/docker-cache@0.3.7
with:
key: docker-app_go
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: kolay0ne
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
push: true
context: "{{defaultContext}}:app_go/"
tags: kolay0ne/app_go:${{ github.ref_name }}