Set github actions for you repo

If you want to run tests/linters against you golang project, place something like the example below in .github/workflows/somename.yml to your project:

name: ci-cd

on:
  push:
    branches:
      - '**'

env:
  GONOSUMDB: "github.com/"
  GOPRIVATE: "github.com/"
jobs:
  ci-cd:
    strategy:
      matrix:
        go-version: [ 1.16.x ]
    runs-on: ubuntu-latest
    steps:
      - name: Install Go
        uses: actions/setup-go@v2
        with:
          go-version: ${{ matrix.go-version }}
      - name: Write .netrc for private go modules
        env:
          NETRC_USER: ${{ secrets.NETRC_USER }}
          NETRC_PASS: ${{ secrets.NETRC_PASS }}
        run: echo "machine github.com login ${{ secrets.NETRC_USER }} password ${{ secrets.NETRC_PASS }}" > $HOME/.netrc
      - name: Checkout the code
        uses: actions/checkout@master
        with:
          fetch-depth: 1
      - name: Run Makefile::ci-cd-check
        run: make ci-cd-check

Good article on that — https://github.com/mvdan/github-actions-golang

LEAVE A COMMENT