Skip to content

Commit cae346e

Browse files
committed
Switch action to “docker” type
Running action as “composite” works, but actions/setup-go@v5 action cannot cache Go dependencies because go.sum is outside workspace: > [debug]Ignore '/home/runner/work/_actions/artyom/update-cloudformation-stack/main/go.sum' since it is not under GITHUB_WORKSPACE. Make this action rely on the prebuilt docker image instead.
1 parent 98b7804 commit cae346e

File tree

4 files changed

+56
-9
lines changed

4 files changed

+56
-9
lines changed

.dockerignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.git
2+
.github

.github/workflows/publish.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Build and publish docker image
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [main]
7+
8+
concurrency: publish
9+
10+
jobs:
11+
build:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 5
14+
permissions:
15+
contents: read
16+
packages: write
17+
18+
steps:
19+
- uses: docker/setup-buildx-action@v3
20+
- uses: docker/login-action@v3
21+
with:
22+
registry: ghcr.io
23+
username: ${{ github.actor }}
24+
password: ${{ github.token }}
25+
- uses: docker/build-push-action@v6
26+
with:
27+
push: true
28+
platforms: |
29+
linux/arm64
30+
linux/amd64
31+
tags: |
32+
ghcr.io/artyom/update-cloudformation-stack:latest
33+
outputs: type=image,oci-mediatypes=true,compression=zstd,compression-level=6,force-compression=true
34+
cache-from: type=gha
35+
cache-to: type=gha,mode=max

Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM --platform=$BUILDPLATFORM public.ecr.aws/docker/library/golang:alpine AS builder
2+
WORKDIR /app
3+
ENV CGO_ENABLED=0 GOTOOLCHAIN=auto
4+
COPY go.mod go.sum ./
5+
RUN go mod download
6+
COPY . .
7+
ARG TARGETOS TARGETARCH
8+
RUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o main
9+
10+
FROM scratch
11+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
12+
COPY --from=builder /app/main /
13+
ENTRYPOINT ["/main"]

action.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,9 @@ inputs:
1414
required: true
1515

1616
runs:
17-
using: composite
18-
steps:
19-
- uses: actions/setup-go@v5
20-
with:
21-
go-version: 'stable'
22-
cache-dependency-path: ${{ github.action_path }}/go.sum
23-
- shell: bash
24-
run: |
25-
go run -C ${{ github.action_path }} . -stack=${{ inputs.stack }} -key=${{ inputs.key }} -value=${{ inputs.value }}
17+
using: docker
18+
image: docker://ghcr.io/artyom/update-cloudformation-stack:latest
19+
args:
20+
- '-stack=${{ inputs.stack }}'
21+
- '-key=${{ inputs.key }}'
22+
- '-value=${{ inputs.value }}'

0 commit comments

Comments
 (0)