-
Notifications
You must be signed in to change notification settings - Fork 20
88 lines (80 loc) · 3.24 KB
/
containers.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
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
name: Build and upload Docker image
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
REGISTRY: ghcr.io/${{ github.repository_owner }}
jobs:
release-please:
permissions:
contents: write
pull-requests: write
runs-on: ubuntu-latest
outputs:
indexer-service-rs: ${{ steps.release-please.outputs['crates/service--tag_name'] }}
indexer-tap-agent: ${{ steps.release-please.outputs['crates/tap-agent--tag_name'] }}
steps:
- name: Release please
id: release-please
uses: googleapis/release-please-action@v4
builds-linux:
runs-on: ubuntu-latest
needs: release-please
strategy:
matrix:
target: [indexer-service-rs, indexer-tap-agent]
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Extract version from tag
id: extract_version
run: |
TAG_NAME="${{ needs.release-please.outputs[matrix.target] }}"
# Extract the version part from tags with prefix "${{ matrix.target }}-" using a regex pattern
if [[ "$TAG_NAME" =~ ^${{ matrix.target }}-(.*)$ ]]; then
VERSION="${BASH_REMATCH[1]}"
else
VERSION=""
fi
echo $VERSION
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Docker meta
id: meta
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
with:
# list of Docker images to use as base name for tags
images: |
${{ env.REGISTRY }}/${{matrix.target}}
# generate Docker tags based on the following events/attributes
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern={{major}}.{{minor}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern={{major}}.{{minor}}.{{patch}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern={{major}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern=v{{version}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern=v{{major}}.{{minor}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern=v{{major}}.{{minor}}.{{patch}},value=${{steps.extract_version.outputs.version}}
type=semver,pattern=v{{major}},value=${{steps.extract_version.outputs.version}}
type=sha
- name: Log in to the Container registry
uses: docker/login-action@7ca345011ac4304463197fac0e56eab1bc7e6af0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
with:
context: ./
push: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
tags: ${{ steps.meta.outputs.tags }}
file: Dockerfile.${{ matrix.target }}