Skip to content

Commit

Permalink
Automatically push container image to Github Container Repo
Browse files Browse the repository at this point in the history
  • Loading branch information
leonardehrenfried committed Jan 3, 2025
1 parent 0aabf02 commit 2dc2a4c
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 40 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: "Container image build"

on:
push:
branches: [ master ]
pull_request:

jobs:

image:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value={{date 'YYYY-MM-DDTHH-mm'}}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.ref == 'refs/heads/master' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
31 changes: 0 additions & 31 deletions .github/workflows/publish.yml

This file was deleted.

21 changes: 12 additions & 9 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
FROM debian:stable-slim
FROM docker.io/golang:bookworm AS builder

LABEL org.opencontainers.image.title="gtfstidy"
LABEL org.opencontainers.image.description="A tool for checking, sanitizing and minimizing GTFS feeds."
LABEL org.opencontainers.image.authors="Patrick Brosi <[email protected]>"
LABEL org.opencontainers.image.documentation="https://github.com/patrickbr/gtfstidy"
LABEL org.opencontainers.image.source="https://github.com/patrickbr/gtfstidy"
LABEL org.opencontainers.image.revision="v0.2"
LABEL org.opencontainers.image.licenses="GPL-2.0"
WORKDIR src

COPY gtfstidy /usr/local/bin/gtfstidy
COPY *.go ./
COPY processors/ ./processors/

RUN go mod init gtfstidy
RUN go mod tidy
RUN go build .

FROM docker.io/debian:stable-slim

COPY --from=builder /go/src/gtfstidy /usr/local/bin/gtfstidy

ENTRYPOINT ["/usr/local/bin/gtfstidy"]

0 comments on commit 2dc2a4c

Please sign in to comment.