Skip to content

Commit

Permalink
Add GA for build/push to GHCR
Browse files Browse the repository at this point in the history
  • Loading branch information
senverbrugge committed Sep 11, 2024
1 parent 9061017 commit 8007450
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 23 deletions.
12 changes: 0 additions & 12 deletions .github/FUNDING.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build and publish container

on:
push:
branches: [master]
workflow_dispatch:
inputs:
reason:
description: 'Why ?'
required: false
default: ''

jobs:
ghr_push:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- name: checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

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

- name: Log-in to ghcr.io
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login https://ghcr.io -u ${{ github.actor }} --password-stdin

- name: Build and push container image
run: |
IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')
# Strip git ref prefix from version
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
# Strip "v" prefix from tag name
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
# when the branch is master, replace master with latest
[ "$VERSION" == "master" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
# Build and Publish container image
docker buildx build --push \
--tag $IMAGE_ID:$VERSION \
--platform linux/amd64,linux/arm64 .
13 changes: 2 additions & 11 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,13 @@
FROM alpine:latest

ARG APPLICATION="myapp"
ARG APPLICATION="autossh"
ARG BUILD_RFC3339="1970-01-01T00:00:00Z"
ARG REVISION="local"
ARG DESCRIPTION="no description"
ARG PACKAGE="user/repo"
ARG VERSION="dirty"

LABEL org.opencontainers.image.ref.name="${PACKAGE}" \
org.opencontainers.image.created=$BUILD_RFC3339 \
org.opencontainers.image.authors="Justin J. Novack <[email protected]>" \
org.opencontainers.image.documentation="https://github.com/${PACKAGE}/README.md" \
org.opencontainers.image.description="${DESCRIPTION}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.source="https://github.com/${PACKAGE}" \
org.opencontainers.image.revision=$REVISION \
org.opencontainers.image.version=$VERSION \
org.opencontainers.image.url="https://hub.docker.com/r/${PACKAGE}/"
LABEL org.opencontainers.image.source="https://github.com/Q24/autossh"

RUN \
apk --no-cache add \
Expand Down

0 comments on commit 8007450

Please sign in to comment.