-
Notifications
You must be signed in to change notification settings - Fork 0
123 lines (121 loc) · 7.7 KB
/
cicd.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: continuous-delivery
on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
tag:
description: "What to tag the deployer image with"
required: true
cnpg_tag:
description: "What version of the CNPG chart to bundle"
required: true
jobs:
build:
name: Build chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GCR
uses: docker/login-action@v2
with:
registry: gcr.io
username: _json_key
password: ${{ secrets.GCR_JSON_KEY }}
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: v3.9.0
id: install
# Steps to run on tag
- name: Parse major, minor, patch from tag
id: semver_parser
uses: booxmedialtd/ws-action-parse-semver@v1
if: ${{ github.event_name != 'workflow_dispatch' }}
with:
input_string: ${{ github.ref }}
version_extractor_regex: '^refs/tags/[v]?(.*)$'
- name: Update CNPG chart by tag
run: make update-chart
if: ${{ github.event_name != 'workflow_dispatch' }}
env:
TAG: "${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}"
- name: Build and push
uses: docker/build-push-action@v4
if: ${{ github.event_name != 'workflow_dispatch' }}
with:
context: .
push: true
provenance: false
tags: |
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:latest
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser.outputs.fullversion }}
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}
build-args: |
TAG=${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}
- name: Pull CNPG image
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
docker pull ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}
- name: Tag CNPG image
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:latest
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser.outputs.fullversion }}
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser.outputs.major }}.${{ steps.semver_parser.outputs.minor }}.${{ steps.semver_parser.outputs.patch }}
- name: Push CNPG image tags
if: ${{ github.event_name != 'workflow_dispatch' }}
run: |
docker image push --all-tags gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg
#####
# Steps to run on dispatch
- name: Parse major, minor, patch from tag
id: semver_parser_dispatch
uses: booxmedialtd/ws-action-parse-semver@v1
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
input_string: ${{ inputs.tag }}
version_extractor_regex: '^[v]?(.*)$'
- name: Update CNPG chart by input
run: make update-chart
if: ${{ github.event_name == 'workflow_dispatch' }}
env:
TAG: ${{ inputs.cnpg_tag }}
- name: Build and push
uses: docker/build-push-action@v4
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
context: .
push: true
provenance: false
tags: |
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:latest
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser_dispatch.outputs.fullversion }}
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}
gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/deployer:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }}
build-args: |
TAG=${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }}
- name: Pull CNPG image
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
docker pull ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }}
- name: Tag CNPG image
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:latest
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.fullversion }}
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}
docker tag ghcr.io/cloudnative-pg/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }} gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg:${{ steps.semver_parser_dispatch.outputs.major }}.${{ steps.semver_parser_dispatch.outputs.minor }}.${{ steps.semver_parser_dispatch.outputs.patch }}
- name: Push CNPG image tags
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
docker image push --all-tags gcr.io/public-edb-ppas/edb-cnpg-gke-autopilot-dev/cloudnative-pg
#####