forked from haxall/haxall
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (59 loc) · 2.05 KB
/
publish-dockerdefault.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Build and Publish Docker Image to GitHub Packages
# This workflow is run on any push to main, or on push tag when it starts with a 'v'
on:
push:
branches:
- main
tags:
- 'v*'
# This enables a workflow to be triggered manually
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository_owner }}/haxall
jobs:
build-and-publish-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout the repository
uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# https://github.com/docker/metadata-action?tab=readme-ov-file#latest-tag
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
flavor: |
latest=auto
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
# tag with version number upon "git push tag"
type=match,pattern=v(.*),group=1
# set latest tag for default branch
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
# leave this on
type=ref,event=branch
# The github 'docker/bake-action' runs into a registry error...
# Using https://github.com/docker/build-push-action
- name: Build & push image with Github Action
uses: docker/build-push-action@v6
with:
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
#since the context is root, that's where the .dockerignore needs to be.
context: "{{defaultContext}}:."
file: ./docker/Dockerfile
push: true
pull: true
build-args:
DB_NAME=haxall