|
| 1 | +name: Docker images for integration tests |
| 2 | + |
| 3 | +on: |
| 4 | +# push: |
| 5 | +# branches: |
| 6 | +# - master |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +env: |
| 10 | + PLATFORMS: "linux/amd64" |
| 11 | + |
| 12 | +jobs: |
| 13 | + list-dockerfiles: |
| 14 | + name: Create list of existing dockerfiles |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + - name: Get file list |
| 20 | + id: set-matrix |
| 21 | + run: | |
| 22 | + # lists all Dockerfile_* and ignore (grep) files with extension (e.g. *.md5) |
| 23 | + # tranforms the file list in JSON array (StackOverflow#10234327) |
| 24 | + # converts the list into objects of dockerfile and image name |
| 25 | + ls integration-tests/Dockerfile_* | |
| 26 | + grep -Ev "\..{0,3}$" | |
| 27 | + jq -R -s 'split("\n")[:-1]' | |
| 28 | + jq '. | map({dockerfile: ., image: sub(".*_"; "")})' > filelist.json |
| 29 | + echo "matrix=$(jq -c . filelist.json)" >> "$GITHUB_OUTPUT" |
| 30 | + outputs: |
| 31 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 32 | + |
| 33 | + docker: |
| 34 | + needs: [list-dockerfiles] |
| 35 | + name: Build and push Docker image |
| 36 | + runs-on: ubuntu-latest |
| 37 | + strategy: |
| 38 | + fail-fast: false |
| 39 | + matrix: |
| 40 | + include: ${{ fromJson(needs.list-dockerfiles.outputs.matrix) }} |
| 41 | + permissions: |
| 42 | + packages: write |
| 43 | + contents: read |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v4 |
| 48 | + with: |
| 49 | + fetch-depth: 0 |
| 50 | + |
| 51 | + - name: Set up QEMU |
| 52 | + uses: docker/setup-qemu-action@v3 |
| 53 | + |
| 54 | + - name: Set up Docker Buildx |
| 55 | + uses: docker/setup-buildx-action@v3 |
| 56 | + |
| 57 | + - name: Login to GHCR |
| 58 | + uses: docker/login-action@v3 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.repository_owner }} |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + |
| 64 | + - name: Extract metadata (tags, labels) for Docker |
| 65 | + id: meta |
| 66 | + uses: docker/metadata-action@v5 |
| 67 | + with: |
| 68 | + images: | |
| 69 | + ghcr.io/${{ github.repository_owner }}/${{ matrix.image }} |
| 70 | +
|
| 71 | + - name: Build and push tag |
| 72 | + uses: docker/build-push-action@v5 |
| 73 | + with: |
| 74 | + context: . |
| 75 | + file: ${{ matrix.dockerfile }} |
| 76 | + push: true |
| 77 | + tags: | |
| 78 | + ghcr.io/${{ github.repository_owner }}/${{ matrix.image }}:latest |
| 79 | + labels: ${{ steps.meta.outputs.labels }} |
| 80 | + platforms: ${{ env.PLATFORMS }} |
0 commit comments