Skip to content

Build and deploy postgres-image #31

Build and deploy postgres-image

Build and deploy postgres-image #31

Workflow file for this run

name: Build and deploy postgres-image
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
paths-ignore:
- '*.md'
workflow_dispatch:
schedule:
- cron: '0 9 * * 2'
env:
GOOGLE_REGISTRY: "europe-north1-docker.pkg.dev"
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
RUNNER_IMG: "gcr.io/distroless/static-debian12"
RUNNERIMG_IDENTITY: "[email protected]"
RUNNERIMG_ISSUER: "https://accounts.google.com"
steps:
- uses: actions/checkout@v4
with:
repository: zalando/spilo
fetch-depth: '0'
fetch-tags: 'true'
- name: Find latest tag
shell: bash
run: |
wanted_tag=$(git tag --list --sort=committerdate | tail -n 1)
echo "Selected tag ${wanted_tag}"
if [[ -z "$wanted_tag" ]]; then
echo "No tags found"
exit 1
fi
if [[ "$wanted_tag" != 4* ]]; then
echo "Wanted tag is not a 4.x version, check release notes and update this test to accept new major version!"
exit 2
fi
git checkout "$wanted_tag"
- name: Install cosign
uses: sigstore/cosign-installer@398d4b0eeef1380460a10c8013a76f728fb906ac # ratchet:sigstore/[email protected]
with:
cosign-release: 'v2.2.1'
- name: Verify runner image
run: cosign verify --certificate-identity ${{ env.RUNNERIMG_IDENTITY }} --certificate-oidc-issuer ${{ env.RUNNERIMG_ISSUER }} ${{ env.RUNNER_IMG }}
- uses: nais/platform-build-push-sign@main # ratchet:exclude
id: build-push-sign
with:
name: postgres-image
context: postgres-appliance
dockerfile: postgres-appliance/Dockerfile
build_args: |
ADDITIONAL_LOCALES=nb_NO
TIMESCALEDB_APACHE_ONLY=false
TIMESCALEDB_TOOLKIT=false
google_service_account: gh-postgres-image
push: ${{ github.actor != 'dependabot[bot]' }}
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
cache_from: type=gha
cache_to: type=gha,mode=max
outputs:
version: "${{ steps.build-push-sign.outputs.version }}"
chart:
permissions:
contents: 'read'
id-token: 'write'
name: Build and push chart
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # ratchet:actions/checkout@v4
- id: 'auth'
name: 'Authenticate to Google Cloud'
if: github.ref == 'refs/heads/main'
uses: 'google-github-actions/auth@b7593ed2efd1c1617e1b0254da33b86225adb2a5' # ratchet:google-github-actions/[email protected]
with:
workload_identity_provider: ${{ secrets.NAIS_IO_WORKLOAD_IDENTITY_PROVIDER }}
service_account: '[email protected]'
token_format: 'access_token'
- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@cb1e50a9932213ecece00a606661ae9ca44f3397' # ratchet:google-github-actions/setup-gcloud@v1
- name: 'Log in to Google Artifact Registry'
if: github.ref == 'refs/heads/main'
run: |-
echo '${{ steps.auth.outputs.access_token }}' | docker login -u oauth2accesstoken --password-stdin https://${{ env.GOOGLE_REGISTRY }}
- uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # ratchet:azure/setup-helm@v3
name: 'Setup Helm'
with:
version: '3.8.0'
- name: Set versions
run: |-
for chart in charts/*; do
yq e '.version = "${{ needs.build.outputs.version }}"' --inplace "${chart}/Chart.yaml"
yq e '.image.tag = "${{ needs.build.outputs.version }}"' --inplace "${chart}/values.yaml"
done
- name: Build Chart
run: |-
for chart in charts/*; do
helm package "$chart"
done
- name: Push Chart
if: github.ref == 'refs/heads/main'
run: |-
for chart in *.tgz; do
helm push "$chart" oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature
done
rollout:
name: Rollout
if: github.actor != 'dependabot[bot]' && github.ref == 'refs/heads/main'
needs:
- build
- chart
runs-on: fasit-deploy
permissions:
id-token: write
steps:
- uses: nais/fasit-deploy@v2 # ratchet:exclude
with:
chart: oci://${{ env.GOOGLE_REGISTRY }}/nais-io/nais/feature/postgres-image
version: ${{ needs.build.outputs.version }}