Skip to content

Commit

Permalink
Use official Docker Actions (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome authored Nov 6, 2024
1 parent 1597945 commit 9a94cd3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
34 changes: 23 additions & 11 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,41 @@
name: Publish to Docker Hub
name: Publish to GitHub Container Registry
on:
release:
types: [published]
jobs:
update:
runs-on: ubuntu-latest
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Get release version
id: get_version
run: echo ::set-env name=RELEASE_VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: jacobtomlinson/gha-find-replace
tags: |
type=semver,pattern={{version}}
type=semver,pattern=v{{major}}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
name: jacobtomlinson/gha-find-replace
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
tags: "latest,${{ env.RELEASE_VERSION }}"

- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
platforms: linux/amd64,linux/arm64
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ WORKDIR /app
COPY . /app

# Statically compile our app for use in a distroless container
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -v -o app .
RUN CGO_ENABLED=0 go build -ldflags="-w -s" -trimpath -v -o app .

# A distroless container image with some basics like SSL certificates
# https://github.com/GoogleContainerTools/distroless
Expand Down

0 comments on commit 9a94cd3

Please sign in to comment.