-
Notifications
You must be signed in to change notification settings - Fork 0
36 lines (32 loc) · 943 Bytes
/
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
34
35
36
name: Build & Push Container Image
on:
push:
branches:
- master
tags:
- v*
jobs:
build:
runs-on: ubuntu-latest
env:
IMAGE: ${{ github.repository }}
steps:
- uses: actions/checkout@v4
- name: Set image version latest
if: github.ref == 'refs/heads/master'
run: echo "VERSION=latest" >> ${GITHUB_ENV}
- name: Set image version from tag
if: startsWith(github.ref, 'refs/tags/v')
run: echo "VERSION=$(echo ${GITHUB_REF#refs/tags/})" >> ${GITHUB_ENV}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v6
with:
push: true
tags: 'ghcr.io/${{ env.IMAGE }}:${{ env.VERSION }}'