Minor code cleanuop #27
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 | |
on: [push] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
cache: true | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: v1.57.2 | |
args: --timeout=1m -e SA5004 | |
release: | |
needs: build | |
if: contains(github.ref, 'refs/tags/v') | |
name: Create Release | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_REPOSITORY: ${{ github.repository_owner }}/testdummy | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v2 | |
- name: Get the version | |
id: get_version | |
run: | | |
echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Docker build | |
uses: docker/build-push-action@v2 | |
with: | |
push: true | |
file: ./Dockerfile | |
build-args: VERSION=${{ steps.get_version.outputs.VERSION }} | |
tags: "ghcr.io/${{ env.DOCKER_REPOSITORY }}:${{ steps.get_version.outputs.VERSION }}" | |
cache-from: type=registry,ref=ghcr.io/${{ env.DOCKER_REPOSITORY }} | |
cache-to: type=registry,ref=ghcr.io/${{ env.DOCKER_REPOSITORY }} | |
platforms: linux/amd64,linux/arm64 | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: true | |
prerelease: true | |
body: | | |
Docker: `docker pull ghcr.io/${{ env.DOCKER_REPOSITORY }}:${{ steps.get_version.outputs.VERSION }}` |