forked from apecloud-inc/spilo
-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (118 loc) · 4.16 KB
/
release-image.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
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
124
125
126
127
128
129
130
131
132
133
134
135
name: RELEASE-IMAGE
on:
workflow_dispatch:
inputs:
image_tag:
description: 'The tag name of image'
required: true
default: ''
pg_version:
description: 'The version of postgres'
required: true
release:
types:
- published
env:
RELEASE_VERSION: ${{ github.ref_name }}
IMAGE_NAME: "apecloud/spilo"
DOCKER_USER: ${{ secrets.DOCKER_REGISTRY_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
ALIYUN_USER: ${{ secrets.ALIYUN_REGISTRY_USER }}
ALIYUN_PASSWORD: ${{ secrets.ALIYUN_REGISTRY_PASSWORD }}
ALIYUN_USER_NEW: ${{ secrets.ALIYUN_USER_NEW }}
ALIYUN_PASSWORD_NEW: ${{ secrets.ALIYUN_PASSWORD_NEW }}
run-name: release image_tag:${{ inputs.image_tag }} pg_version:${{ inputs.pg_version }}
jobs:
image-tag:
runs-on: ubuntu-latest
outputs:
tag-name: ${{ steps.get_tag_name.outputs.tag_name }}
steps:
- name: Get Tag Name
id: get_tag_name
run: |
TAG_NAME=${{ inputs.image_tag }}
#if [ -z "$TAG_NAME" ]; then
# TAG_NAME=${{ env.RELEASE_VERSION }}
#fi
#TAG_NAME="${TAG_NAME/v/}"
echo tag_name=$TAG_NAME >> $GITHUB_OUTPUT
release-image:
needs: image-tag
name: Push ${{ matrix.registry }}
strategy:
fail-fast: false
matrix:
registry: [ docker.io, apecloud-registry.cn-zhangjiakou.cr.aliyuncs.com, infracreate-registry.cn-zhangjiakou.cr.aliyuncs.com ]
runs-on: ubuntu-latest
permissions:
contents: 'read'
packages: 'write'
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install flake8 and docker-compose
run: python -m pip install flake8 docker-compose==1.17.1
- name: Derive spilo image name
id: image
working-directory: postgres-appliance
run: |
IMAGE="${{ matrix.registry }}/${{ env.IMAGE_NAME }}:${{ needs.image-tag.outputs.tag-name }}"
echo "NAME=$IMAGE" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- if: ${{ contains(matrix.registry, 'docker') }}
name: Login to ${{ matrix.registry }}
uses: docker/login-action@v2
with:
registry: ${{ matrix.registry }}
username: ${{ env.DOCKER_USER }}
password: ${{ env.DOCKER_PASSWORD }}
- if: ${{ contains(matrix.registry, 'aliyuncs') && ! contains(matrix.registry, 'infracreate') }}
name: Login to ${{ matrix.registry }}
uses: docker/login-action@v2
with:
registry: ${{ matrix.registry }}
username: ${{ env.ALIYUN_USER }}
password: ${{ env.ALIYUN_PASSWORD }}
- if: ${{ contains(matrix.registry, 'aliyuncs') && contains(matrix.registry, 'infracreate') }}
name: Login to ${{ matrix.registry }}
uses: docker/login-action@v2
with:
registry: ${{ matrix.registry }}
username: ${{ env.ALIYUN_USER_NEW }}
password: ${{ env.ALIYUN_PASSWORD_NEW }}
- name: Build and export to local docker for testing
uses: docker/build-push-action@v3
with:
context: "postgres-appliance/"
load: true
tags: ${{ steps.image.outputs.NAME }}
build-args: |
PGVERSION=${{ inputs.pg_version }}
PGOLDVERSIONS=${{ inputs.pg_old_versions }}
- name: Test spilo docker image
continue-on-error: true
env:
SPILO_TEST_IMAGE: "${{ steps.image.outputs.NAME }}"
run: |
bash postgres-appliance/tests/test_spilo.sh
- name: Build arm64 additionally and push multi-arch image to ${{ matrix.registry }}
uses: docker/build-push-action@v3
with:
context: "postgres-appliance/"
push: true
tags: "${{ steps.image.outputs.NAME }}"
platforms: linux/amd64,linux/arm64
build-args: |
PGVERSION=${{ inputs.pg_version }}
PGOLDVERSIONS=