Skip to content

Commit

Permalink
add github action workflow to build container
Browse files Browse the repository at this point in the history
  • Loading branch information
jdratlif committed Apr 26, 2024
1 parent 5363739 commit 26e6869
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions .github/workflows/build-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
name: Build Container

on:
push:
branches: [main]
tags: ["*"]
workflow_dispatch:

env:
REGISTRY: ghcr.io
REPO: ${{ github.repository }}

jobs:
build-container:
name: Build Container
runs-on: ubuntu-latest

permissions:
contents: read
packages: write

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

- name: Generate image name for docker
run: |
echo "IMAGE_NAME=${REPO,,}" >> ${GITHUB_ENV}
- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

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

- name: Extract metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=latest
type=sha
- name: Build/push container image
uses: docker/build-push-action@v5
with:
push: true
labels: ${{ steps.metadata.outputs.labels }}
tags: ${{ steps.metadata.outputs.tags }}

0 comments on commit 26e6869

Please sign in to comment.