-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (86 loc) · 2.6 KB
/
publish.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: Publish
on:
# Tests docker build without pushing
push:
branches:
- main
pull_request:
# Manually, or from another workflow, trigger build of a new version
workflow_call:
inputs:
version:
description: 'SemVer version to create'
required: true
type: string
publish:
description: 'Publish the new version'
required: true
type: boolean
workflow_dispatch:
inputs:
version:
description: "Manually create a new SemVer version, will not create a release or tag, use with caution"
required: true
type: string
publish:
description: 'Publish the new version'
required: false
type: boolean
default: false
concurrency:
# Cancel existing runs when pushing to the same branch of a PR
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
build:
runs-on: ubuntu-latest
name: Build
timeout-minutes: 15
outputs:
version: ${{ steps.meta.outputs.version }}
steps:
- uses: actions/checkout@v4
- uses: docker/metadata-action@v5
name: Docker meta
id: meta
with:
images: |
ghcr.io/allexveldman/pyoci
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=ref,event=tag
type=semver,value=${{ inputs.version }},pattern={{version}}
type=semver,value=${{ inputs.version }},pattern={{major}}.{{minor}}
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./
file: docker/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
load: true
push: ${{ inputs.publish || false }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Smoke-test the image
# The smoke test contains a build of the image but because the previous
# step defines `load: true` the entire build will be from cache.
- uses: extractions/setup-just@v2
- uses: snok/install-poetry@v1
- run: just test-smoke
- run: docker compose logs pyoci
working-directory: ./docker