Skip to content

Add ARM64

Add ARM64 #10

Workflow file for this run

name: ci
on:
pull_request:
push:
branches:
- master
schedule:
# See https://crontab.guru/weekly
- cron: 0 0 * * 0
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v6
- name: Set PY
run: |
echo "PY=$(python -c 'import hashlib,sys;print(hashlib.sha256(sys.version.encode()+sys.executable.encode()).hexdigest())')" >> $GITHUB_ENV
- uses: actions/cache@v4
with:
path: ~/.cache/pre-commit
key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }}
- uses: pre-commit/action@v1.0.1
build-test-push:
if: github.ref == 'refs/heads/master' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
runs-on: ubuntu-latest
needs: pre-commit
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
pg_version:
- "18"
- "17"
- "16"
- "15"
- "14"
- "13"
- "12"
- "11"
- "10"
- "9.6"
env:
DOCKER_PLATFORM: linux/amd64,linux/arm64
# Indicates what's the equivalent to tecnativa/postgres-autoconf:latest image
LATEST_RELEASE: "18-alpine"
DOCKER_REPO: "" # Set in the next step
BASE_TAG: ${{ matrix.pg_version }}-alpine
DOCKER_TAG: ${{ github.event_name == 'pull_request' && format('{0}-test-pr{1}', matrix.pg_version, github.event.number) || format('{0}-alpine', matrix.pg_version) }}
GIT_SHA1: ${{ github.sha }}
PG_VERSION: ${{ matrix.pg_version }}
# Github does not allow evaluating a secret in an if condition, so we need to set them as environment variables
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_LOGIN: ${{ secrets.DOCKERHUB_LOGIN }}
steps:
# Image repo names have to be lowercase.
- name: Set image repository name
run: |
if [ "$GITHUB_REPOSITORY" = "Tecnativa/docker-postgres-autoconf" ]; then
echo "DOCKER_REPO=tecnativa/postgres-autoconf" >> "$GITHUB_ENV"
else
echo "DOCKER_REPO=${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"
fi
- uses: actions/checkout@v4
- uses: actions/setup-python@v6
- run: pip install -r tests/ci-requirements.txt
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
# Build images
- run: ./hooks/build
# Test
- run: python -m unittest tests.test -v
# Push
- name: Push Docker Image to Docker Hub
if: env.DOCKERHUB_TOKEN && env.DOCKERHUB_LOGIN
env:
REGISTRY_HOST: docker.io
REGISTRY_TOKEN: ${{ env.DOCKERHUB_TOKEN }}
REGISTRY_USERNAME: ${{ env.DOCKERHUB_LOGIN }}
run: ./hooks/push
- name: Push Docker Image to GitHub Registry
env:
REGISTRY_HOST: ghcr.io
REGISTRY_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
REGISTRY_USERNAME: ${{ secrets.BOT_LOGIN || github.repository_owner }}
run: ./hooks/push