-
Notifications
You must be signed in to change notification settings - Fork 15
47 lines (47 loc) · 1.6 KB
/
docker.yaml
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
name: Publish Docker image
on:
push:
tags:
- '*'
release:
types: [created]
workflow_dispatch:
jobs:
push_to_registry:
name: Push Docker image to GitHub registry
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to GitHub registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >>$GITHUB_OUTPUT
id: extract_branch
- name: Extract tag name
shell: bash
run: echo "tag=$(echo ${GITHUB_REF#refs/tags/})" >>$GITHUB_OUTPUT
id: extract_tag
- name: Build and push - tag releaes
if: startsWith(github.ref, 'refs/tags/')
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/yanu:${{ steps.extract_tag.outputs.tag }},ghcr.io/${{ github.repository_owner }}/yanu:latest
- name: Build and push - branch
if: startsWith(github.ref, 'refs/heads/')
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/yanu:${{ steps.extract_branch.outputs.branch }}-${{ github.sha }},ghcr.io/${{ github.repository_owner }}/yanu:latest