chore: dockerize and goreleaser #1
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: docker-go-scripts | |
on: | |
push: | |
branches: | |
- "master" | |
tags: | |
- 'v*' | |
permissions: | |
contents: read | |
packages: write | |
jobs: | |
build-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
# Seems required for cache | |
- uses: actions/setup-go@v5 | |
- name: Login to Docker registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Go Build Cache for Docker | |
uses: actions/cache@v3 | |
with: | |
path: go-build-cache | |
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go-build-cache- | |
- name: inject go-build-cache into docker | |
uses: reproducible-containers/[email protected] | |
with: | |
cache-source: go-build-cache | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
tags: | | |
type=raw,value=latest | |
- name: Build and push | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
pull: true | |
push: true | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} |