Skip to content

Commit

Permalink
Setup GitHub action to build contiainer
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Hocutt <[email protected]>
  • Loading branch information
jaredhocutt committed Feb 12, 2024
1 parent 65faac9 commit cacf6b2
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions .github/workflows/build_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@ on:
branches:
- main

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

jobs:
build:
name: Build container image
build-and-push-image:
runs-on: ubuntu-latest

permissions:
contents: read
packages: write
Expand All @@ -16,24 +20,32 @@ jobs:
- name: Clone the repository
uses: actions/checkout@v4

- name: Use Buildah to create container image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: ocp4-disconnected
tags: latest ${{ github.sha }}
containerfiles: |
./Containerfile
- name: Push container image to registry
id: push-to-ghcr
uses: redhat-actions/push-to-registry@v2
- name: Log in to the container registry
uses: docker/login-action@v3
with:
image: ${{ steps.build-image.outputs.image }}
tags: ${{ steps.build-image.outputs.tags }}
registry: ghcr.io/${{ github.repository_owner }}
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Output image URL
run: echo "Image pushed to ${{ steps.push-to-ghcr.outputs.registry-paths }}"
- name: Extract container metadata
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{ is_default_branch }}
type=sha,format=long
# - name: Build and push container image
# uses: docker/build-push-action@v5
# id: build-and-push
# with:
# context: .
# file: ./Containerfile
# push: true
# tags: >-
# ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,
# ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}

# - name: Output image metadata
# run: echo "${{ steps.build-and-push.outputs.metadata }}"

0 comments on commit cacf6b2

Please sign in to comment.