Dev image for pgskipper-operator: 1074 - elbe0116 #1074
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: Build Pgskipper Components | |
| run-name: "Dev image for ${{ github.event.repository.name }}: ${{ github.run_number }} - ${{ github.actor }}" | |
| on: | |
| release: | |
| types: [created] | |
| push: | |
| branches: | |
| - "main" | |
| paths-ignore: | |
| - "docs/**" | |
| - "CODE-OF-CONDUCT.md" | |
| - "CONTRIBUTING.md" | |
| - "LICENSE" | |
| - "README.md" | |
| - "SECURITY.md" | |
| pull_request: | |
| branches: | |
| - "**" | |
| paths-ignore: | |
| - "docs/**" | |
| - "CODE-OF-CONDUCT.md" | |
| - "CONTRIBUTING.md" | |
| - "LICENSE" | |
| - "README.md" | |
| - "SECURITY.md" | |
| workflow_dispatch: | |
| inputs: | |
| publish_docker: | |
| description: "Publish images to ghcr.io/<repository owner> (lowercase)" | |
| type: boolean | |
| default: false | |
| required: false | |
| tags: | |
| description: "Optional extra tags for metadata-action" | |
| type: string | |
| required: false | |
| default: "" | |
| replace_symbol: | |
| description: "Replace symbol for metadata-action ref names" | |
| type: string | |
| required: false | |
| default: "_" | |
| permissions: | |
| contents: read | |
| concurrency: | |
| group: ${{ github.ref_type == 'branch' && format('build-branch-{0}', github.ref_name) || format('build-{0}', github.sha) }} | |
| cancel-in-progress: ${{ github.ref_name != 'main' }} | |
| env: | |
| TAG_NAME: ${{ github.event.release.tag_name || github.head_ref || github.ref_name }} | |
| # Fork PRs run on the base repo: GITHUB_TOKEN cannot push org packages; still build with push=false. | |
| # Pushes on your fork (push event) publish to ghcr.io/<fork owner>/... via GITHUB_GROUP below. | |
| PUSH: ${{ (github.event_name != 'workflow_dispatch' || inputs.publish_docker) && github.actor != 'dependabot[bot]' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} | |
| jobs: | |
| prepare: | |
| name: "Prepare Images and Metadata" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| components: ${{ steps.load.outputs.components }} | |
| platforms: ${{ steps.load.outputs.platforms }} | |
| tags: "${{ steps.meta.outputs.result }}" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| persist-credentials: true | |
| fetch-depth: 0 | |
| - name: Changed Files | |
| if: github.event_name != 'release' && github.event_name != 'workflow_dispatch' | |
| id: changed-files | |
| uses: tj-actions/changed-files@24d32ffd492484c1d75e0c0b894501ddb9d30d62 # v47 | |
| with: | |
| json: true | |
| write_output_files: true # .github/outputs/all_changed_files.json | |
| - id: load | |
| name: Load Components and Platforms | |
| run: | | |
| if [[ "$GITHUB_EVENT_NAME" == "release" || "$GITHUB_EVENT_NAME" == "workflow_dispatch" ]]; then | |
| components=$(jq -c '.components' .github/build-config.cfg) | |
| fi | |
| if [[ "$GITHUB_EVENT_NAME" == "pull_request" || "$GITHUB_EVENT_NAME" == "push" ]]; then | |
| all_changed_files=$(jq -c '.' .github/outputs/all_changed_files.json) | |
| if [ "$all_changed_files" != "null" ]; then | |
| echo "all_changed_files=${all_changed_files}" | |
| chmod +x .github/scripts/matrix.sh | |
| components=$(./.github/scripts/matrix.sh ".github/build-config.cfg" ".github/outputs/all_changed_files.json") | |
| fi | |
| fi | |
| echo "components=${components}" | |
| echo "components=${components}" >> "$GITHUB_OUTPUT" | |
| echo "platforms=$(jq -c '.platforms' .github/build-config.cfg)" >> "$GITHUB_OUTPUT" | |
| - name: Create tags for images | |
| uses: netcracker/qubership-workflow-hub/actions/metadata-action@8d542a426ce561c7dce745f6b9cee068d1d7e101 #2.0.10 | |
| id: meta | |
| with: | |
| default-template: "{{ref-name}}" | |
| extra-tags: ${{ github.event.inputs.tags || '' }} | |
| replace-symbol: ${{ github.event.inputs.replace_symbol || '_' }} | |
| build: | |
| name: ${{ matrix.component.name }} Image Build | |
| needs: [prepare] | |
| runs-on: ubuntu-22.04 | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| component: ${{ fromJson(needs.prepare.outputs.components) }} | |
| steps: | |
| - name: Validate | |
| if: ${{ github.event_name == 'workflow_dispatch' && startsWith(github.ref, 'refs/tags/') }} | |
| run: | | |
| echo -e "\033[91mManual workflow run on tags is not allowed!\033[0m" | |
| exit 1 | |
| - name: Checkout | |
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| with: | |
| persist-credentials: false | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${GITHUB_ACTOR} | |
| password: ${{secrets.GITHUB_TOKEN}} | |
| - name: Prepare Tag | |
| run: echo "TAG_NAME=$(echo ${TAG_NAME} | sed 's@refs/tags/@@;s@refs/heads/@@;s@/@_@g')" >> $GITHUB_ENV | |
| - name: Prepare registry namespace | |
| env: | |
| REPO_OWNER: ${{ github.repository_owner }} | |
| run: echo "GITHUB_GROUP=$(echo "$REPO_OWNER" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" | |
| - name: Get package IDs for delete | |
| id: get-ids-for-delete | |
| uses: Netcracker/get-package-ids@84bc8eb8bed50218be76e671b3a24c35a1300979 | |
| with: | |
| component-name: ${{ matrix.component.name }} | |
| component-tag: ${{ env.TAG_NAME }} | |
| access-token: ${{secrets.GITHUB_TOKEN}} | |
| if: ${{ env.PUSH }} | |
| - name: Build and push | |
| uses: docker/build-push-action@16ebe778df0e7752d2cfcbd924afdbbd89c1a755 # v6.6.1 | |
| with: | |
| no-cache: true | |
| context: ${{ matrix.component.context }} | |
| file: ${{ matrix.component.file }} | |
| platforms: ${{ needs.prepare.outputs.platforms }} | |
| push: ${{ env.PUSH }} | |
| build-args: PG_VERSION=${{ matrix.component.pg_version }} | |
| tags: ghcr.io/${{ env.GITHUB_GROUP }}/${{ matrix.component.name }}:${{ env.TAG_NAME }} | |
| provenance: false | |
| - uses: actions/delete-package-versions@e5bc658cc4c965c472efe991f8beea3981499c55 # v5.0.0 | |
| with: | |
| package-name: ${{ matrix.component.name }} | |
| package-type: 'container' | |
| package-version-ids: ${{ steps.get-ids-for-delete.outputs.ids-for-delete }} | |
| if: ${{ steps.get-ids-for-delete.outputs.ids-for-delete != '' }} |