Build and Push weekly Multi-Arch Execution Environment #42
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
| # yamllint disable rule:line-length rule:truthy rule:document-start | |
| # (Long run blocks and workflow syntax required; path comment above) | |
| #.github/workflows/build-ee-weekly.yml | |
| name: Build and Push weekly Multi-Arch Execution Environment | |
| on: | |
| workflow_dispatch: | |
| schedule: | |
| - cron: '15 3 * * 0' # Runs at 3:15 AM UTC on Sunday | |
| env: | |
| REGISTRY: ghcr.io | |
| IMAGE_NAME: ${{ github.repository_owner }}/sap-ee | |
| ANSIBLER_BUILDER_CONFIG: execution-environment-weekly.yml | |
| jobs: | |
| generate-tag: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| image_tag: ${{ steps.date.outputs.tag}} | |
| steps: | |
| - name: Get current date for image tag | |
| id: date | |
| run: echo "tag=$(date +'dev%y%m%d')" >> $GITHUB_OUTPUT | |
| build: | |
| runs-on: ubuntu-latest | |
| needs: generate-tag | |
| permissions: | |
| contents: read | |
| packages: write | |
| strategy: | |
| fail-fast: false | |
| # Matrix-Strategie, um Builds parallel auszuführen, falls Runner verfügbar sind. | |
| # Hier wird jedoch auf einem einzigen Runner emuliert. | |
| matrix: | |
| platform: | |
| - amd64 | |
| - arm64 | |
| - ppc64le | |
| steps: | |
| # Checkout repo | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| # Dieser Schritt ist entscheidend: Er konfiguriert QEMU und binfmt_misc auf dem Runner. | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v4 | |
| with: | |
| platforms: all # Stellt sicher, dass alle Architekturen emuliert werden können | |
| # Anmeldung bei der Container Registry | |
| - name: Log in to the Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Schritt 1: Build-Kontext mit ansible-builder erstellen | |
| - name: Create build context | |
| run: | | |
| pip install ansible-builder | |
| ansible-builder create -v 3 -f ${{ env.ANSIBLER_BUILDER_CONFIG }} | |
| # Schritt 2: Image für die jeweilige Plattform bauen und pushen | |
| # Das Image wird direkt mit einem architektur-spezifischen Tag gepusht. | |
| - name: Build and push platform-specific image | |
| run: | | |
| podman build \ | |
| --platform=linux/${{ matrix.platform }} \ | |
| --tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }}_${{ matrix.platform }} \ | |
| --layers=false \ | |
| -f context/Containerfile context | |
| podman push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }}_${{ matrix.platform }} | |
| # Ein separater Job, der nach Abschluss aller plattform-spezifischen Builds läuft. | |
| create-manifest: | |
| runs-on: ubuntu-latest | |
| needs: [ generate-tag, build ] # Stellt sicher, dass dieser Job erst nach dem 'build'-Job startet und den output von generate-tag hat | |
| steps: | |
| - name: Log in to the Container Registry | |
| uses: docker/login-action@v4 | |
| with: | |
| registry: ${{ env.REGISTRY }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # Erstellt die Manifest-Liste und fügt die zuvor gepushten Images hinzu. | |
| - name: Create and push manifest list | |
| run: | | |
| podman manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} | |
| podman manifest add ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }}_amd64 | |
| podman manifest add ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }}_arm64 | |
| podman manifest add ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }}_ppc64le | |
| podman manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} | |
| podman tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ needs.generate-tag.outputs.image_tag }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-dev | |
| podman manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-dev |