Separate GH Action of build and deploy

pull/289/head
Rizky Maulana Nugraha 2021-01-27 20:52:43 +07:00
rodzic 8cca0c8007
commit d38b05d57c
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: F08C600969AC1656
2 zmienionych plików z 92 dodań i 82 usunięć

Wyświetl plik

@ -52,11 +52,6 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Do we need to generate locale?
id: is_generate_locale
if: github.ref == env.latest-ref
run: echo "::set-output name=is_generate::"
- name: Build base image
id: docker_build_base
uses: docker/build-push-action@v2
@ -66,7 +61,7 @@ jobs:
push: false
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
build-args: |
GENERATE_ALL_LOCALE=${{ steps.is_generate_locale.outputs.is_generate }}
GENERATE_ALL_LOCALE=0
DISTRO=${{ matrix.distro }}
IMAGE_VERSION=${{ matrix.imageVersion }}
IMAGE_VARIANT=${{ matrix.imageVariant }}
@ -157,79 +152,3 @@ jobs:
pushd scenario_tests/${{ matrix.scenario }}
./test.sh
popd
deploy-image:
# Identical to the build-image step, but now push to registry
runs-on: ubuntu-latest
env:
latest-ref: refs/heads/develop
strategy:
matrix:
postgresMajorVersion:
- 13
postgisMajorVersion:
- 3
postgisMinorRelease:
- 1
include:
- distro: debian
imageVersion: bullseye
imageVariant: slim
needs: [ build-image, run-scenario-tests ]
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get build cache
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-${{ github.sha }}
restore-keys: |
buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Do we need to generate locale?
id: is_generate_locale
if: github.ref == env.latest-ref
run: echo "::set-output name=is_generate::"
- name: Build base image
id: docker_build_base
uses: docker/build-push-action@v2
with:
context: base_build
file: base_build/Dockerfile
push: ${{ github.ref == env.latest-ref }}
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
build-args: |
GENERATE_ALL_LOCALE=${{ steps.is_generate_locale.outputs.is_generate }}
DISTRO=${{ matrix.distro }}
IMAGE_VERSION=${{ matrix.imageVersion }}
IMAGE_VARIANT=${{ matrix.imageVariant }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build prod image
id: docker_build_prod
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: ${{ github.ref == env.latest-ref }}
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:${{ matrix.postgresMajorVersion }}-${{ matrix.postgisMajorVersion }}.${{ matrix.postgisMinorRelease }}
build-args: |
DISTRO=${{ matrix.distro }}
IMAGE_VERSION=${{ matrix.imageVersion }}
IMAGE_VARIANT=${{ matrix.imageVariant }}
POSTGRES_MAJOR_VERSION=${{ matrix.postgresMajorVersion }}
POSTGIS_MAJOR_VERSION=${{ matrix.postgisMajorVersion }}
POSTGIS_MINOR_VERSION=${{ matrix.postgresMinorVersion }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache

Wyświetl plik

@ -0,0 +1,91 @@
name: deploy-image
on:
workflow_dispatch:
# inputs:
# distro:
# description: Base image distro
# required: true
# default: debian
# imageVersion:
# description: Base distro image version/release
# required: true
# default: bullseye
# imageVariant:
# description: Base image variant
# required: true
# default: slim
workflow_run:
workflows:
- build-latest
branches:
- develop
types:
- completed
jobs:
deploy-image:
runs-on: ubuntu-latest
env:
latest-ref: refs/heads/develop
strategy:
matrix:
postgresMajorVersion:
- 13
postgisMajorVersion:
- 3
postgisMinorRelease:
- 1
include:
- distro: debian
imageVersion: bullseye
imageVariant: slim
steps:
- uses: actions/checkout@v2
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Get build cache
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-${{ github.sha }}
restore-keys: |
buildx-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}-
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build base image
id: docker_build_base
uses: docker/build-push-action@v2
with:
context: base_build
file: base_build/Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:base-${{ matrix.distro }}-${{ matrix.imageVersion }}-${{ matrix.imageVariant }}
build-args: |
DISTRO=${{ matrix.distro }}
IMAGE_VERSION=${{ matrix.imageVersion }}
IMAGE_VARIANT=${{ matrix.imageVariant }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Build prod image
id: docker_build_prod
uses: docker/build-push-action@v2
with:
context: .
file: Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_REPO }}/postgis:${{ matrix.postgresMajorVersion }}-${{ matrix.postgisMajorVersion }}.${{ matrix.postgisMinorRelease }}
build-args: |
DISTRO=${{ matrix.distro }}
IMAGE_VERSION=${{ matrix.imageVersion }}
IMAGE_VARIANT=${{ matrix.imageVariant }}
POSTGRES_MAJOR_VERSION=${{ matrix.postgresMajorVersion }}
POSTGIS_MAJOR_VERSION=${{ matrix.postgisMajorVersion }}
POSTGIS_MINOR_VERSION=${{ matrix.postgresMinorVersion }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache