generated from NezuChan/template
-
Notifications
You must be signed in to change notification settings - Fork 0
63 lines (56 loc) · 1.94 KB
/
docker.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Build & Push to container registry
on:
release:
types: [created]
push:
branches:
- "**"
pull_request:
branches:
- "**"
paths:
- "Dockerfile"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@755da8c3cf115ac066823e79a1e1788f8940201b # v3.2.0
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@8c0edbc76e98fa90f69d9a2c020dcb50019dc325 # v2.2.1
- name: Login to GitHub Container Registry
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a # v2.1.0
if: ${{ github.event_name != 'pull_request' }}
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract tag name
id: tags
if: ${{ github.event_name == 'release' }}
run: echo ::set-output name=name::${GITHUB_REF##*/}
- name: Extract flavor
id: flavor
run: if [ "${{ github.event_name }}" = "release" ]; then echo ::set-output name=name::; else echo ::set-output name=name::-dev; fi
- name: Generate Docker image metadata
uses: docker/metadata-action@57396166ad8aefe6098280995947635806a0e6ea # v4.1.1
id: img_meta
with:
flavor: |
latest=auto
suffix=${{ steps.flavor.outputs.name }}
images: ghcr.io/nezuchan/nezly
tags: |
${{ steps.tags.outputs.name }}
latest
- name: Build and push
id: docker_build
uses: docker/build-push-action@c56af957549030174b10d6867f20e78cfd7debc5 # v3.2.0
with:
context: ./
tags: ${{ steps.img_meta.outputs.tags }}
labels: ${{ steps.img_meta.outputs.labels }}
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha,mode=max
cache-to: type=gha,mode=max