-
Notifications
You must be signed in to change notification settings - Fork 1
33 lines (31 loc) · 1.03 KB
/
build_and_push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Build and push container image
on:
push:
branches:
- main
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get IMAGE_ID
run: |
echo "IMAGE_ID=$(echo ghcr.io/${{ github.repository }} | tr '[A-Z]' '[a-z]')" >> $GITHUB_ENV
- name: Get SHORT_SHA
run: |
echo "SHORT_SHA=$(echo ${GITHUB_SHA} | cut -c1-7)" >> $GITHUB_ENV
- name: Install podman
run: |
sudo apt-get update
sudo apt-get install -y podman
- name: Login to ghcr.io
run: |
echo ${{ secrets.GITHUB_TOKEN }} | podman login ghcr.io --username ${{ github.actor }} --password-stdin
- name: Build container image
run: |
podman build -t ${{ env.IMAGE_ID }}:${{ env.SHORT_SHA }} -t ${{ env.IMAGE_ID }}:latest .
- name: Push container image
run: |
podman push ${{ env.IMAGE_ID }}:${{ env.SHORT_SHA }}
podman push ${{ env.IMAGE_ID }}:latest