Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Add GH workflow to build and push container image #10

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/build_and_push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build and push container image

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install podman
run: |
sudo apt-get update
sudo apt-get install -y podman
- name: Get short commit SHA
run: echo "SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV
- name: Build container image
run: |
podman build -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.SHORT_SHA }} -t ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest .
- name: Login to ghcr.io
run: |
echo ${{ secrets.GITHUB_TOKEN }} | podman login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Push container image
run: |
podman push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:${{ env.SHORT_SHA }}
podman push ghcr.io/${{ github.repository_owner }}/${{ github.repository }}:latest