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
46name: ๐๏ธ๐ค Build and publish ๐ณ images
on:
push:
branches: ["main"]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
name: ๐๏ธ๐ค Build and push ๐ณ image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: ๐๐ฆ Checkout repository.
uses: actions/checkout@v3
- name: ๐๐ฆ Login to container registry
uses: docker/login-action@v2.1.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: ๐๐ Extract metadata (๐ท๏ธ, ๐ท๏ธ) for ๐ณ
id: meta
uses: docker/metadata-action@v4.3.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,enable=true,priority=100,prefix={{branch}}-,suffix=,format=short
type=raw,value=latest,enable={{is_default_branch}}
- name: ๐๏ธ๐ค Build and push ๐ณ image
uses: docker/build-push-action@v4.0.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}