ci added golang #67
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: Build Docker Image - CI | |
on: | |
release: | |
types: | |
- published | |
push: | |
branches: | |
- main | |
- master | |
- 'release-\d.\d\d' | |
jobs: | |
build: | |
name: Build and push docker image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-go@v3 | |
- name: generate test coverage | |
run: go test ./pkg/... -coverprofile=./cover.out -covermode=atomic -coverpkg=./... | |
- name: check test coverage | |
uses: vladopajic/go-test-coverage@v2 | |
with: | |
# Configure action using config file (option 1) | |
config: ./.testcoverage.yml | |
- name: Set image tag | |
shell: bash | |
run: | | |
image_tag=latest | |
if [ ${{ github.ref }} == 'refs/heads/release-\d.\d\d' ]; then | |
branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} | |
version_digits=$(echo ${branch} | tr -d -c 0-9) | |
image_tag=v$(echo ${version_digits} | cut -b 1).$(echo ${version_digits:1}) | |
fi | |
echo "IMAGE_TAG=${image_tag}" >> $GITHUB_OUTPUT | |
id: set_image_tag | |
- name: Set up QEMU | |
run: | | |
ls -l | |
cat main/main.go | |
echo "Variable is ${{ steps.set_image_tag.outputs.IMAGE_TAG }}" |