-
-
Notifications
You must be signed in to change notification settings - Fork 59
64 lines (56 loc) · 2.21 KB
/
docker.yml
File metadata and controls
64 lines (56 loc) · 2.21 KB
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
name: "Build and Publish Docker Images"
on:
push:
tags:
- "docker-*"
workflow_call:
inputs:
tag:
required: true
type: string
# Triggers building, tagging and pushing of Docker image files
# Uses tag name to extract channel (latest/stable)
# e.g. docker-10.21.1p-latest -> latest
jobs:
publish-docker:
name: Publish Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
# Checkout branch which triggered the action
ref: ${{ github.ref }}
- name: Extract Channel from workflow input, else tag name
id: channel
run: |
channel=$(cut -d - -f 3 <<< "${{ inputs.tag || github.ref_name }}")
echo "channel=$channel" >> $GITHUB_OUTPUT
- name: Generate image tags from push tags/workflow input
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5
with:
images: ghcr.io/extrange/ibkr
flavor: |
latest=false
# Tags for major, major.minor and stable/latest
# Extracted from either pushed tag, or inputs.tag if called from workflow
# https://github.com/docker/metadata-action/blob/8e5442c4ef9f78752691e2d8f8d19755c6f78e81/src/meta.ts#L230-L233
tags: |
type=match,pattern=docker-(\d+.\d+),group=1,value=${{ inputs.tag}}
type=match,pattern=docker-(\d+.\d+.\w+),group=1,value=${{ inputs.tag}}
type=match,pattern=docker-(\d+.\d+.\w+)+\-(stable|latest),group=2,value=${{ inputs.tag}}
- name: Log in to the Container registry
uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6
with:
# Build context
context: ${{ steps.channel.outputs.channel }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}