-
Notifications
You must be signed in to change notification settings - Fork 3
55 lines (52 loc) · 1.79 KB
/
docker-release.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
name: Docker Release
on:
release:
types:
- published
push:
branches:
- dev
env:
IMAGE_REGISTRY: ghcr.io
IMAGE_PATH: ${{ github.repository }}
IMAGE_TAG: ${{ github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Get latest release
id: latest_release
uses: pozetroninc/github-action-get-latest-release@master
with:
repository: ${{ github.repository }}
excludes: prerelease, draft
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push (latest release)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release == github.ref_name }} # run only on latest release
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:latest
- name: Build and push (release)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'release' && steps.latest_release.outputs.release != github.ref_name }} # run only on release (not latest)
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}
- name: Build and push (push)
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'push' }} # run only on push (to dev)
with:
push: true
tags:
- ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_PATH }}:${{ env.IMAGE_TAG }}