forked from tripsolutions/postgres-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (50 loc) · 1.94 KB
/
main.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
name: build container
on:
# triggered by user action only
workflow_dispatch:
inputs:
PG_VERSION:
description: 'Postgres version'
required: true
default: '15.3'
EXTENSIONS:
description: 'Postgres extensions to install'
required: true
default: 'cron timescaledb'
TIMESCALEDB_VERSION:
description: 'TimescaleDB version'
required: true
default: '2.11.0'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/login-action@v2
# authenticate ghcr.io
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: calculate image tag
id: vars
run: |
# step 1: order extensions alphabetically
export EXTENSIONS=$(echo "${{ github.event.inputs.EXTENSIONS }}" | tr ' ' '\n' | sort | tr '\n' ' ')
# this is good but it leaves a trailing space. Fix it:
export EXTENSIONS=$(echo "${EXTENSIONS}" | sed 's/ $//g')
# step 2: if exists, replace extension timescaledb with its versioned equivalent; replace spaces with dashes
export EXTENSIONS=$(echo "${{ github.event.inputs.EXTENSIONS }}" | sed 's/timescaledb/timescaledb-${{ github.event.inputs.TIMESCALEDB_VERSION }}/g;s/ /-/g')
# step 3: output variable to github action
echo "IMAGE_TAG=${{ github.event.inputs.PG_VERSION }}-${EXTENSIONS}" >> $GITHUB_OUTPUT
- uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ghcr.io/${{ github.repository_owner }}/postgresql:${{ steps.vars.outputs.IMAGE_TAG }}
build-args: |
POSTGRESQL_VERSION=${{ github.event.inputs.PG_VERSION }}
EXTENSIONS=${{ github.event.inputs.EXTENSIONS }}
TIMESCALEDB_VERSION=${{ github.event.inputs.TIMESCALEDB_VERSION }}