continuous-delivery #1143
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: continuous-delivery | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| cnpg_branch: | |
| description: "Name of the branch/tag used to build & load the operator (leave empty for default)" | |
| required: false | |
| test_depth: | |
| description: 'E2E test level: 0(highest) to 4(lowest) (leave empty for default)' | |
| required: false | |
| feature_type: | |
| description: 'E2E feature type filter. See https://github.com/cloudnative-pg/cloudnative-pg/blob/main/contribute/e2e_testing_environment/README.md#using-feature-type-test-selectionfilter' | |
| required: false | |
| schedule: | |
| - cron: '0 1 * * *' | |
| defaults: | |
| run: | |
| # default failure handling for shell scripts in 'run' steps | |
| shell: 'bash -Eeuo pipefail -x {0}' | |
| permissions: read-all | |
| jobs: | |
| build-pg: | |
| name: Build the Trunk of PostgreSQL | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| outputs: | |
| pg_image: ${{ env.PG_IMAGE }} | |
| pg_major: ${{ env.PG_MAJOR }} | |
| cnpg_branch: ${{ env.CNPG_BRANCH }} | |
| test_depth: ${{ env.TEST_DEPTH }} | |
| feature_type: ${{ env.FEATURE_TYPE }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v5 | |
| - name: Set env variables from defaults.json | |
| run: | | |
| for key in $(jq -r 'keys[]' defaults.json); do | |
| echo "$key=$(cat defaults.json | jq -r --arg key "$key" '.[$key]')" >> $GITHUB_ENV | |
| done | |
| # Inputs have priority over defaults.json. | |
| - name: Evaluate E2E workflow inputs | |
| run: | | |
| if [[ -n "${{ github.event.inputs.cnpg_branch }}" ]]; then | |
| echo "CNPG_BRANCH=${{ github.event.inputs.cnpg_branch }}" >> $GITHUB_ENV | |
| fi | |
| if [[ -n "${{ github.event.inputs.test_depth }}" ]]; then | |
| echo "TEST_DEPTH=${{ github.event.inputs.test_depth }}" >> $GITHUB_ENV | |
| fi | |
| if [[ -n "${{ github.event.inputs.feature_type }}" ]]; then | |
| echo "FEATURE_TYPE=${{ github.event.inputs.feature_type }}" >> $GITHUB_ENV | |
| fi | |
| - name: Log in to the GitHub Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and push | |
| uses: docker/bake-action@v6 | |
| id: build | |
| env: | |
| environment: production | |
| registry: ghcr.io/${{ github.repository_owner }} | |
| revision: ${{ github.sha }} | |
| pgMajor: ${{ env.PG_MAJOR }} | |
| with: | |
| push: true | |
| # Get a list of the images that were built and pushed. We only care about a single tag for each image. | |
| - name: Generated images | |
| id: images | |
| run: | | |
| echo "PG_IMAGE=$(echo '${{ steps.build.outputs.metadata }}' | jq -r '.["minimal"].["image.name"]' | grep -oP '[^,]*\d{12}[^,]*')" >> $GITHUB_ENV | |
| call-reusable-e2e: | |
| if: github.event_name == 'schedule' | |
| needs: | |
| - build-pg | |
| uses: ./.github/workflows/reusable-e2e.yml | |
| permissions: | |
| packages: write | |
| with: | |
| postgres_img: ${{ needs.build-pg.outputs.pg_image }} | |
| major_version: ${{ needs.build-pg.outputs.pg_major }} | |
| cnpg_branch: ${{ needs.build-pg.outputs.cnpg_branch }} | |
| test_depth: ${{ needs.build-pg.outputs.test_depth }} | |
| feature_type: ${{ needs.build-pg.outputs.feature_type }} |