@@ -22,6 +22,10 @@ inputs:
2222 github_token :
2323 required : true
2424 description : GitHub token used for authentication with GHCR
25+ build_args :
26+ required : false
27+ default : ' '
28+ description : Additional build arguments for Docker build
2529
2630runs :
2731 using : composite
@@ -70,13 +74,29 @@ runs:
7074 echo "Docker service status:"
7175 sudo systemctl --no-pager -l -o short status docker
7276
77+ - name : Configure Go Build Cache
78+ shell : bash
79+ run : |
80+ export GOPATH=/tmp/go
81+ export GOCACHE=/tmp/go-cache
82+ export GOMODCACHE=/tmp/go-mod-cache
83+ mkdir -p $GOPATH $GOCACHE $GOMODCACHE
84+ echo "GOPATH=$GOPATH" >> $GITHUB_ENV
85+ echo "GOCACHE=$GOCACHE" >> $GITHUB_ENV
86+ echo "GOMODCACHE=$GOMODCACHE" >> $GITHUB_ENV
87+ CORES=$(nproc)
88+ GOMAXPROCS=$((CORES-1))
89+ echo "GOMAXPROCS=$GOMAXPROCS" >> $GITHUB_ENV
90+
7391 - name : Setup QEMU
7492 uses : docker/setup-qemu-action@v3
7593 with :
7694 platforms : amd64,arm64
7795
7896 - name : Set Up Docker Buildx
7997 uses : docker/setup-buildx-action@v3
98+ with :
99+ buildkitd-flags : --debug
80100
81101 - name : Login to GitHub Container Registry
82102 uses : docker/login-action@v3
@@ -92,13 +112,27 @@ runs:
92112 REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
93113 echo "repo_name=${REPO_NAME}" >> $GITHUB_OUTPUT
94114
115+ - name : Prepare Build Args
116+ id : build-args
117+ shell : bash
118+ run : |
119+ BUILD_ARGS="GOPROXY=https://proxy.golang.org,direct"
120+ BUILD_ARGS="${BUILD_ARGS} GOMAXPROCS=${GOMAXPROCS}"
121+
122+ if [[ -n "${{ inputs.build_args }}" ]]; then
123+ BUILD_ARGS="${BUILD_ARGS} ${{ inputs.build_args }}"
124+ fi
125+
126+ echo "args=${BUILD_ARGS}" >> $GITHUB_OUTPUT
127+ echo "Prepared build args: ${BUILD_ARGS}"
128+
95129 - name : Add Docker Tags
96130 id : meta
97131 uses : docker/metadata-action@v5
98132 with :
99133 images : ghcr.io/${{ steps.repo-info.outputs.repo_name }}/${{ inputs.image }}
100134 tags : |
101- type=raw,latest
135+ type=raw,value= latest
102136 type=sha
103137
104138 - name : Build and Push
@@ -109,5 +143,8 @@ runs:
109143 file : ${{ inputs.dockerfile }}
110144 push : ${{ inputs.push }}
111145 tags : ${{ steps.meta.outputs.tags }}
112- cache-from : type=gha
113- cache-to : type=gha,ignore-error=true
146+ cache-from : type=gha,scope=${{ inputs.image }}-${{ github.workflow }}
147+ cache-to : type=gha,mode=max,scope=${{ inputs.image }}-${{ github.workflow }},ignore-error=true
148+ build-args : ${{ steps.build-args.outputs.args }}
149+ pull : true
150+ outputs : type=registry,compression=zstd,compression-level=3,force-compression=true
0 commit comments