Skip to content

Commit

Permalink
Add publish container github action and remove old action
Browse files Browse the repository at this point in the history
  • Loading branch information
ottolote committed Apr 23, 2024
1 parent f2a6865 commit dfdebb1
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 37 deletions.
87 changes: 87 additions & 0 deletions .github/workflows/publish-container-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@

name: Docker Image Publish

on:
push:
branches: [ "main", "ol/containerize" ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
# pull_request:
# branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write

steps:
-
name: Checkout
uses: actions/checkout@v4
-
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

# Version from git describe (https://git-scm.com/docs/git-describe)
- name: Get version
id: version
run: |
output=$(git describe --tags --always --dirty)
echo ::set-output name=git_version::$output
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: downcase REPO
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./publish
push: ${{ github.event_name != 'pull_request' }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
file: ./publish/Dockerfile
tags: ${{ steps.meta.outputs.tags }}
platforms: linux/amd64,linux/arm/v7,linux/arm64
37 changes: 0 additions & 37 deletions .github/workflows/publisher.yml

This file was deleted.

0 comments on commit dfdebb1

Please sign in to comment.