Skip to content

Build, test and deploy from GitHub Actions #1

Build, test and deploy from GitHub Actions

Build, test and deploy from GitHub Actions #1

Workflow file for this run

name: Build and push
on:
push:
pull_request:
jobs:
base-images:
# we cannot offer this caching optimizations to forks as it would require access to our Dockerhub
if: github.repository == "pgautoupgrade/docker-pgautoupgrade"
runs-on: ubuntu-latest
strategy:
matrix:
pg_version:
- "9.5"
- "9.6"
- "10"
- "11"
- "12"
- "13"
- "14"
- "15"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
push: true
platforms: linux/amd64,linux/arm64
build-args: |
"PGTARGET=16"
target: "build-${{ matrix.pg_version }}"
tags: "pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}"
cache-to: type=inline
cache-from: type=registry,ref=pgautoupgrade/pgautoupgrade:build-${{ matrix.pg_version }}
target-images:
runs-on: ubuntu-latest
needs: base-images
# otherwise, on forks it would skip the build entirely (because the base step does not run)
if: always()
env:
# but they can still use our public caches, but they might be outdated and it still triggers a full rebuild
TARGET_TAG: ${{ github.ref == "refs/heads/main" && "alpine3.18" || "dev-alpine3.18" }}

Check failure on line 56 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / Build and push

Invalid workflow file

The workflow is not valid. .github/workflows/ci.yml (Line: 56, Col: 19): Unexpected symbol: '"refs/heads/main"'. Located at position 15 within expression: github.ref == "refs/heads/main" && "alpine3.18" || "dev-alpine3.18" .github/workflows/ci.yml (Line: 57, Col: 19): Unrecognized named-value: 'env'. Located at position 1 within expression: env.TARGET_TAG
CACHE_FROM: |
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.5
type=registry,ref=pgautoupgrade/pgautoupgrade:build-9.6
type=registry,ref=pgautoupgrade/pgautoupgrade:build-10
type=registry,ref=pgautoupgrade/pgautoupgrade:build-11
type=registry,ref=pgautoupgrade/pgautoupgrade:build-12
type=registry,ref=pgautoupgrade/pgautoupgrade:build-13
type=registry,ref=pgautoupgrade/pgautoupgrade:build-14
type=registry,ref=pgautoupgrade/pgautoupgrade:build-15
type=registry,ref=pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ env.TARGET_TAG }}
strategy:
matrix:
pg_target:
- "13"
- "14"
- "15"
- "16"
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
if: github.repository == "pgautoupgrade/docker-pgautoupgrade"
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build image
uses: docker/build-push-action@v5
with:
load: true
tags: "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ env.TARGET_TAG }}"
build-args: |
"PGTARGET=${{ matrix.pg_target }}"
cache-to: type=inline
cache-from: "${{ env.CACHE_FROM }}"
- name: Checkout code
uses: actions/checkout@v4
- name: Test image
run: |
make test
env:
PGTARGET: ${{ matrix.pg_target }}
- name: Push image
if: github.repository == "pgautoupgrade/docker-pgautoupgrade" && github.ref == "refs/heads/main"
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
tags: "pgautoupgrade/pgautoupgrade:${{ matrix.pg_target }}-${{ env.TARGET_TAG }}"
push: true
cache-to: type=inline
cache-from: "${{ env.CACHE_FROM }}"