-
Notifications
You must be signed in to change notification settings - Fork 3
50 lines (50 loc) · 1.73 KB
/
docker-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
49
50
name: Publish Docker image
on:
workflow_dispatch:
inputs:
tag:
description: 'The tag to build'
required: false
type: string
default: 'main'
push:
branches: [main]
tags: ['v*']
paths: ['src/**', '.github/workflows/**', 'docker/**', 'Dockerfile']
env:
IMAGE_NAME: ${{ github.repository }}
REGISTRY: ghcr.io
jobs:
push_to_registry:
name: Push Docker image to GitHub Packages
runs-on: ubuntu-latest
env:
PACKAGE_VERSION: ${{github.event.inputs.tag || github.ref_name || 'v0.1.0'}}
steps:
- id: get-version
run: |
PACKAGE_VERSION=$(echo $PACKAGE_VERSION | sed s/^v//)
echo "::set-output name=version::$PACKAGE_VERSION"
- name: Check out the repo
uses: actions/checkout@v4
with:
submodules: true
ref: ${{github.event.inputs.tag || ''}}
- name: Login to docker registry
uses: docker/[email protected]
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_PUBLISH_TOKEN }}
registry: ${{ env.REGISTRY }}
- name: Push to GitHub Packages - Nightly
if: github.ref == 'refs/heads/main' || github.event.inputs.tag == 'main'
uses: docker/[email protected]
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
- name: Push to GitHub Packages - Release
if: startsWith(github.ref, 'refs/tags/v') || startsWith(github.event.inputs.tag, 'v')
uses: docker/[email protected]
with:
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.get-version.outputs.version }}