-
Notifications
You must be signed in to change notification settings - Fork 2
121 lines (110 loc) · 4.41 KB
/
push-compare.yml
File metadata and controls
121 lines (110 loc) · 4.41 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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
name: Push and compare postgres
# This workflow is required to upgrade several postgres versions from the push-scheduled workflow.
on:
workflow_call:
inputs:
postgres-major-version:
description: "Postgres major version to release."
type: string
required: true
services:
description: "Json list with postgres services to upgrade."
type: string
required: true
secrets:
COSIGN_KEY_OPENSIGHT:
required: true
COSIGN_KEY_PASSWORD_OPENSIGHT:
required: true
GREENBONE_BOT_TOKEN:
required: true
jobs:
compare:
runs-on: self-hosted-generic
steps:
- name: Compare postgres annotation org.opencontainers.image.created
id: compare
uses: greenbone/actions/oci-info@v3
with:
command: compare-tag-annotation
reg-domain: ${{ vars.GREENBONE_REGISTRY }}
reg-auth-domain: "${{ vars.GREENBONE_REGISTRY }}/service"
reg-auth-service: harbor-registry
user: ${{ secrets.GREENBONE_REGISTRY_USER }}
password: ${{ secrets.GREENBONE_REGISTRY_TOKEN }}
repository: opensight-postgres
namespace: opensight-dev
compare-repository: postgres
tag: ${{ inputs.postgres-major-version }}
mode: lt
- name: Get dockerhub postgres service tags
if: ${{ steps.compare.outputs.output == 'true' }}
id: dtags
uses: greenbone/actions/oci-info@v3
with:
repository: postgres
namespace: library
reg-domain: registry-1.docker.io
reg-auth-domain: auth.docker.io
reg-auth-service: registry.docker.io
- name: Get opensight-postgres service tags
if: ${{ steps.compare.outputs.output == 'true' }}
id: tags
uses: greenbone/actions/oci-info@v3
with:
reg-domain: ${{ vars.GREENBONE_REGISTRY }}
reg-auth-domain: "${{ vars.GREENBONE_REGISTRY }}/service"
reg-auth-service: harbor-registry
user: ${{ secrets.GREENBONE_REGISTRY_USER }}
password: ${{ secrets.GREENBONE_REGISTRY_TOKEN }}
repository: opensight-postgres
namespace: opensight-dev
- name: Increment opensight-postgres service version
if: ${{ steps.compare.outputs.output == 'true' }}
id: version
shell: bash
run: |
set +e
# Get latest postgres minor version from dockerhub filtered by major version.
dt="$(echo -e '${{ steps.dtags.outputs.output }}' | grep -E '^${{ inputs.postgres-major-version }}.[0-9]+$' | sort -Vr | sed q)"
echo "Current postgres version on dockerhub: $dt"
if ! [ "$dt" ]; then
echo 'No postgres release on dockerhub found for major version: ${{ inputs.postgres-major-version }}'
exit 1
fi
IFS='.' read -r -a dv <<< "$dt"
minor="${dv[1]}"
if ! [ "$minor" ]; then
echo "No postgres minor version found on dockerhub: $dt"
exit 2
fi
# Get the latest opensight-postgres tag filtered by dockerhub postgres minor version.
t="$(echo -e '${{ steps.tags.outputs.output }}' | grep -E "^${{ inputs.postgres-major-version }}.$minor.[0-9]+$" | sort -Vr | sed q)"
if [ "$t" ]; then
echo "Current opensight-postgres version: $t"
# Increment patch level
IFS='.' read -r -a v <<< "$t"
if ! [ -v v[2] ]; then
echo "No patch level found in opensearch-postgres version: $t"
exit 3
fi
patch=$((v[2] + 1))
version="${{ inputs.postgres-major-version }}.$minor.$patch"
else
echo "New minor postgres version found on dockerhub: ${{ inputs.postgres-major-version }}.$minor"
version="${{ inputs.postgres-major-version }}.$minor.0"
fi
echo "New opensight-postgres version: $version"
echo "output=$version" >> $GITHUB_OUTPUT
outputs:
compare: ${{ steps.compare.outputs.output }}
version: ${{ steps.version.outputs.output }}
push-postgres:
needs: compare
if: ${{ needs.compare.outputs.compare == 'true' }}
uses: ./.github/workflows/push.yml
with:
postgres-major-version: ${{ inputs.postgres-major-version }}
services: ${{ inputs.services }}
version: ${{ needs.compare.outputs.version }}
secrets: inherit