|
| 1 | +name: Build & Publish |
| 2 | + |
| 3 | +permissions: |
| 4 | + contents: read |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - 'master' |
| 10 | + paths: |
| 11 | + - 'apache-1.6.x/**' |
| 12 | + - 'fpm-1.6.x/**' |
| 13 | + - 'fpm-alpine-1.6.x/**' |
| 14 | + - '.github/workflows/*-1.6.yml' |
| 15 | + tags: |
| 16 | + - '1.6.*' |
| 17 | + schedule: |
| 18 | + # Rebuild images each monday early morning to ensure a fresh base OS. |
| 19 | + - cron: "23 2 * * 1" |
| 20 | + workflow_dispatch: |
| 21 | + |
| 22 | +jobs: |
| 23 | + build-and-testvariants: |
| 24 | + name: Build image variants and run tests |
| 25 | + runs-on: ubuntu-latest |
| 26 | + strategy: |
| 27 | + fail-fast: false |
| 28 | + max-parallel: 10 |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + # The tags are pretty repetetive, but we can't properly script things using GitHub actions, and want to avoid scripting all the things manually, so we live with it. |
| 32 | + - variant: 'apache' |
| 33 | + test-files: 'apache-postgres' |
| 34 | + docker-tag: | |
| 35 | + roundcube/roundcubemail:1.6.x-apache |
| 36 | + roundcube/roundcubemail:1.6.15-apache |
| 37 | + roundcube/roundcubemail:latest-apache |
| 38 | + roundcube/roundcubemail:latest |
| 39 | + docker-tag-nonroot: | |
| 40 | + roundcube/roundcubemail:1.6.x-apache-nonroot |
| 41 | + roundcube/roundcubemail:1.6.15-apache-nonroot |
| 42 | + roundcube/roundcubemail:latest-apache-nonroot |
| 43 | + roundcube/roundcubemail:latest-nonroot |
| 44 | + test-tag: roundcube/roundcubemail:latest-apache |
| 45 | + test-tag-nonroot: roundcube/roundcubemail:latest-apache-nonroot |
| 46 | + http-port-nonroot: '8000' |
| 47 | + - variant: 'fpm' |
| 48 | + test-files: 'fpm-postgres' |
| 49 | + docker-tag: | |
| 50 | + roundcube/roundcubemail:1.6.x-fpm |
| 51 | + roundcube/roundcubemail:1.6.15-fpm |
| 52 | + roundcube/roundcubemail:latest-fpm |
| 53 | + docker-tag-nonroot: | |
| 54 | + roundcube/roundcubemail:1.6.x-fpm-nonroot |
| 55 | + roundcube/roundcubemail:1.6.15-fpm-nonroot |
| 56 | + roundcube/roundcubemail:latest-fpm-nonroot |
| 57 | + test-tag: roundcube/roundcubemail:latest-fpm |
| 58 | + test-tag-nonroot: roundcube/roundcubemail:latest-fpm-nonroot |
| 59 | + - variant: 'fpm-alpine' |
| 60 | + test-files: 'fpm-postgres' |
| 61 | + docker-tag: | |
| 62 | + roundcube/roundcubemail:1.6.x-fpm-alpine |
| 63 | + roundcube/roundcubemail:1.6.15-fpm-alpine |
| 64 | + roundcube/roundcubemail:latest-fpm-alpine |
| 65 | + docker-tag-nonroot: | |
| 66 | + roundcube/roundcubemail:1.6.x-fpm-alpine-nonroot |
| 67 | + roundcube/roundcubemail:1.6.15-fpm-alpine-nonroot |
| 68 | + roundcube/roundcubemail:latest-fpm-alpine-nonroot |
| 69 | + test-tag: roundcube/roundcubemail:latest-fpm-alpine |
| 70 | + test-tag-nonroot: roundcube/roundcubemail:latest-fpm-alpine-nonroot |
| 71 | + target: 'root' |
| 72 | + steps: |
| 73 | + - name: Checkout repository |
| 74 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 75 | + - name: Set up Docker |
| 76 | + # This step is required to enable the containerd image store, which is required by the cache type=gha |
| 77 | + uses: docker/setup-docker-action@efe9e3891a4f7307e689f2100b33a155b900a608 # v4.5.0 |
| 78 | + with: |
| 79 | + daemon-config: | |
| 80 | + { |
| 81 | + "debug": true, |
| 82 | + "features": { |
| 83 | + "containerd-snapshotter": true |
| 84 | + } |
| 85 | + } |
| 86 | + - name: Set up QEMU |
| 87 | + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 |
| 88 | + - name: Set up Docker Buildx |
| 89 | + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 |
| 90 | + with: |
| 91 | + buildkitd-flags: --debug |
| 92 | + |
| 93 | + - name: Build rootful image to test for "${{ matrix.variant }}" |
| 94 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 |
| 95 | + with: |
| 96 | + context: ${{ matrix.variant }} |
| 97 | + load: true |
| 98 | + tags: ${{ matrix.docker-tag }} |
| 99 | + target: root |
| 100 | + cache-from: type=gha |
| 101 | + cache-to: type=gha,mode=max |
| 102 | + |
| 103 | + - name: Test rootful image for "${{ matrix.variant }}" |
| 104 | + env: |
| 105 | + ROUNDCUBEMAIL_TEST_IMAGE: ${{ matrix.test-tag }} |
| 106 | + HTTP_PORT: '80' |
| 107 | + run: | |
| 108 | + set -exu; |
| 109 | + for testFile in ${{ join(matrix.test-files, ' ') }}; |
| 110 | + do |
| 111 | + docker compose -f ./tests/docker-compose.test-${testFile}.yml down -v |
| 112 | + docker compose -f ./tests/docker-compose.test-${testFile}.yml up --exit-code-from=sut --abort-on-container-exit |
| 113 | + done |
| 114 | +
|
| 115 | + # Only log into docker now, so we benefit from the automatic caching of upstream images. |
| 116 | + - name: Get docker hub username |
| 117 | + id: creds |
| 118 | + run: echo 'username=${{ secrets.DOCKER_PULL_USERNAME }}' >> $GITHUB_OUTPUT |
| 119 | + - name: Login to Docker Hub |
| 120 | + if: steps.creds.outputs.username != '' |
| 121 | + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 |
| 122 | + with: |
| 123 | + username: ${{ secrets.DOCKER_PULL_USERNAME }} |
| 124 | + password: ${{ secrets.DOCKER_PUSH_PASSWORD }} |
| 125 | + |
| 126 | + - name: Build and push rootful images for "${{ matrix.variant }} for all platforms" |
| 127 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 |
| 128 | + with: |
| 129 | + context: ${{ matrix.variant }} |
| 130 | + platforms: "linux/arm64,linux/arm/v6,linux/arm/v7,linux/386,linux/amd64," |
| 131 | + push: true |
| 132 | + tags: ${{ matrix.docker-tag }} |
| 133 | + target: root |
| 134 | + cache-from: type=gha |
| 135 | + cache-to: type=gha,mode=max |
| 136 | + |
| 137 | + - name: Build nonroot image to test for "${{ matrix.variant }}" |
| 138 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 |
| 139 | + with: |
| 140 | + context: ${{ matrix.variant }} |
| 141 | + load: true |
| 142 | + tags: ${{ matrix.docker-tag-nonroot }} |
| 143 | + target: nonroot |
| 144 | + cache-from: type=gha |
| 145 | + cache-to: type=gha,mode=max |
| 146 | + |
| 147 | + - name: Test nonroot image for "${{ matrix.variant }}" |
| 148 | + env: |
| 149 | + ROUNDCUBEMAIL_TEST_IMAGE: ${{ matrix.test-tag-nonroot }} |
| 150 | + HTTP_PORT: ${{ matrix.http-port-nonroot || '80' }} |
| 151 | + run: | |
| 152 | + set -exu; |
| 153 | + for testFile in ${{ join(matrix.test-files, ' ') }}; |
| 154 | + do |
| 155 | + docker compose -f ./tests/docker-compose.test-${testFile}.yml down -v |
| 156 | + docker compose -f ./tests/docker-compose.test-${testFile}.yml up --exit-code-from=sut --abort-on-container-exit |
| 157 | + done |
| 158 | +
|
| 159 | + - name: Build and push nonroot images for "${{ matrix.variant }} for all platforms" |
| 160 | + uses: docker/build-push-action@471d1dc4e07e5cdedd4c2171150001c434f0b7a4 # v6.15.0 |
| 161 | + with: |
| 162 | + context: ${{ matrix.variant }} |
| 163 | + platforms: "linux/arm64,linux/arm/v6,linux/arm/v7,linux/386,linux/amd64," |
| 164 | + push: true |
| 165 | + tags: ${{ matrix.docker-tag-nonroot }} |
| 166 | + target: nonroot |
| 167 | + cache-from: type=gha |
| 168 | + cache-to: type=gha,mode=max |
0 commit comments