Skip to content

Externalize docker API version to const #15 #143

Externalize docker API version to const #15

Externalize docker API version to const #15 #143

Workflow file for this run

name: build
on:
push:
branches:
tags:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
services:
mongo:
image: mongo:5.0
ports:
- 27017:27017
steps:
- name: set up go 1.21
uses: actions/setup-go@v4
with:
go-version: "1.21"
id: go
- name: checkout
uses: actions/checkout@v3
- name: build and test
run: |
go test -v -timeout=100s -covermode=count -coverprofile=$GITHUB_WORKSPACE/profile.cov_tmp ./...
cat $GITHUB_WORKSPACE/profile.cov_tmp | grep -v "mocks" | grep -v "_mock" > $GITHUB_WORKSPACE/profile.cov
working-directory: app
env:
GOFLAGS: "-mod=vendor"
TZ: "America/Chicago"
MONGO_TEST: mongodb://127.0.0.1:27017
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
- name: submit coverage
run: |
go install github.com/mattn/goveralls@latest
goveralls -service="github" -coverprofile=$GITHUB_WORKSPACE/profile.cov
env:
COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: set up QEMU
uses: docker/setup-qemu-action@v2
- name: set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: available platforms
run: echo ${{ steps.buildx.outputs.platforms }}
- name: build and deploy master image to ghcr.io and dockerhub
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/sys-agent:${ref} -t ${USERNAME}/sys-agent:${ref} .
- name: deploy tagged (latest) to ghcr.io and dockerhub
if: ${{ startsWith(github.ref, 'refs/tags/') }}
env:
GITHUB_PACKAGE_TOKEN: ${{ secrets.PKG_TOKEN }}
DOCKER_HUB_TOKEN: ${{ secrets.DOCKER_HUB_TOKEN }}
USERNAME: ${{ github.actor }}
GITHUB_SHA: ${{ github.sha}}
GITHUB_REF: ${{ github.ref}}
run: |
ref="$(echo ${GITHUB_REF} | cut -d'/' -f3)"
echo GITHUB_REF - $ref
echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io -u ${USERNAME} --password-stdin
echo ${DOCKER_HUB_TOKEN} | docker login -u ${USERNAME} --password-stdin
docker buildx build --push \
--build-arg CI=github --build-arg GITHUB_SHA=${GITHUB_SHA} --build-arg GIT_BRANCH=${ref} \
--platform linux/amd64,linux/arm/v7,linux/arm64 \
-t ghcr.io/${USERNAME}/sys-agent:${ref} -t ghcr.io/${USERNAME}/sys-agent:latest \
-t ${USERNAME}/sys-agent:${ref} -t ${USERNAME}/sys-agent:latest .