-
Notifications
You must be signed in to change notification settings - Fork 0
48 lines (39 loc) · 1.22 KB
/
build-and-publish.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
37
38
39
40
41
42
43
44
45
46
47
48
name: Build and Publish
on:
push:
branches:
- main
tags:
- "*"
pull_request:
jobs:
build-and-publish-docker-image:
name: Build docker image and push to repository
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Packages
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build image and push to GitHub Container Registry as specific tag
uses: docker/build-push-action@v3
if: ${{ github.ref_type == 'tag' }}
with:
context: ./
platforms: linux/amd64
tags: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}"
push: true
- name: Build image and push to GitHub Container Registry as latest
uses: docker/build-push-action@v3
if: ${{ github.ref_type != 'tag' }}
with:
context: ./
platforms: linux/amd64
tags: "ghcr.io/${{ github.repository }}:latest"
push: ${{ github.ref == 'refs/heads/main' }}