|
| 1 | +# SPDX-License-Identifier: MIT |
| 2 | +# Copyright (c) 2026 Netresearch DTT GmbH |
| 3 | +# |
| 4 | +# The daily rebuild is the whole point of this repository: upstream refreshes |
| 5 | +# its image when phpMyAdmin is released, we refresh ours when its base picks up |
| 6 | +# fixes. Two variants per run — `pinned` ships the libraries as released, |
| 7 | +# `rolling` refreshes them within phpMyAdmin's own constraints. |
| 8 | + |
| 9 | +name: build |
| 10 | + |
| 11 | +on: |
| 12 | + schedule: |
| 13 | + - cron: '0 3 * * *' # 03:00 UTC, before the workday |
| 14 | + push: |
| 15 | + branches: [main] |
| 16 | + paths-ignore: |
| 17 | + - 'docs/**' |
| 18 | + - 'examples/**' |
| 19 | + - '**.md' |
| 20 | + pull_request: |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +env: |
| 24 | + REGISTRY: ghcr.io |
| 25 | + IMAGE_NAME: ${{ github.repository_owner }}/phpmyadmin-php-fpm |
| 26 | + |
| 27 | +permissions: {} |
| 28 | + |
| 29 | +concurrency: |
| 30 | + group: build-${{ github.ref }} |
| 31 | + # A scheduled multi-arch rebuild must not be interrupted half-pushed. |
| 32 | + cancel-in-progress: ${{ github.event_name != 'schedule' }} |
| 33 | + |
| 34 | +jobs: |
| 35 | + build: |
| 36 | + name: ${{ matrix.variant }} |
| 37 | + runs-on: ubuntu-latest |
| 38 | + permissions: |
| 39 | + contents: read |
| 40 | + packages: write |
| 41 | + id-token: write |
| 42 | + attestations: write |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + matrix: |
| 46 | + include: |
| 47 | + - variant: pinned |
| 48 | + rolling: "false" |
| 49 | + suffix: "" |
| 50 | + - variant: rolling |
| 51 | + rolling: "true" |
| 52 | + suffix: "-rolling" |
| 53 | + steps: |
| 54 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 55 | + with: |
| 56 | + persist-credentials: false |
| 57 | + |
| 58 | + - name: Read the pinned phpMyAdmin release |
| 59 | + id: version |
| 60 | + run: echo "pma=$(cat .phpmyadmin-version)" >> "$GITHUB_OUTPUT" |
| 61 | + |
| 62 | + - uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0 |
| 63 | + - uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 |
| 64 | + |
| 65 | + # Pushing only happens from main and the schedule: a pull request must be |
| 66 | + # able to prove the image still builds without being able to publish it. |
| 67 | + - name: Log in to the registry |
| 68 | + if: github.event_name != 'pull_request' |
| 69 | + uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 70 | + with: |
| 71 | + registry: ${{ env.REGISTRY }} |
| 72 | + username: ${{ github.actor }} |
| 73 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 74 | + |
| 75 | + - name: Tags and labels |
| 76 | + id: meta |
| 77 | + uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 |
| 78 | + with: |
| 79 | + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 80 | + flavor: | |
| 81 | + suffix=${{ matrix.suffix }},onlatest=true |
| 82 | + tags: | |
| 83 | + type=raw,value=latest,enable={{is_default_branch}} |
| 84 | + type=raw,value=${{ steps.version.outputs.pma }},enable={{is_default_branch}} |
| 85 | + type=raw,value=${{ steps.version.outputs.pma }}-{{date 'YYYYMMDD'}},enable={{is_default_branch}} |
| 86 | + type=ref,event=pr |
| 87 | +
|
| 88 | + - name: Build and push |
| 89 | + id: push |
| 90 | + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 |
| 91 | + with: |
| 92 | + context: . |
| 93 | + platforms: linux/amd64,linux/arm64 |
| 94 | + push: ${{ github.event_name != 'pull_request' }} |
| 95 | + load: ${{ github.event_name == 'pull_request' }} |
| 96 | + tags: ${{ steps.meta.outputs.tags }} |
| 97 | + labels: ${{ steps.meta.outputs.labels }} |
| 98 | + cache-from: type=gha,scope=${{ matrix.variant }} |
| 99 | + cache-to: type=gha,mode=max,scope=${{ matrix.variant }} |
| 100 | + build-args: | |
| 101 | + PMA_VERSION=${{ steps.version.outputs.pma }} |
| 102 | + ROLLING_DEPS=${{ matrix.rolling }} |
| 103 | + BUILD_DATE=${{ github.event.repository.updated_at }} |
| 104 | + VCS_REF=${{ github.sha }} |
| 105 | + # The SBOM and provenance attestations travel with the manifest, so |
| 106 | + # a consumer can ask the registry what is inside the image it pulled. |
| 107 | + sbom: true |
| 108 | + provenance: mode=max |
| 109 | + |
| 110 | + - name: Attest the build |
| 111 | + if: github.event_name != 'pull_request' |
| 112 | + uses: actions/attest-build-provenance@977bb373ede98d70efdf65b84cb5f73e068dcc2a # v3.0.0 |
| 113 | + with: |
| 114 | + subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} |
| 115 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 116 | + push-to-registry: true |
| 117 | + |
| 118 | + # Proves the image actually serves phpMyAdmin, not merely that it built. |
| 119 | + # A dependency refresh that breaks the application would pass every static |
| 120 | + # check and fail here. |
| 121 | + smoke-test: |
| 122 | + name: smoke test (${{ matrix.variant }}) |
| 123 | + needs: build |
| 124 | + if: github.event_name != 'pull_request' |
| 125 | + runs-on: ubuntu-latest |
| 126 | + permissions: |
| 127 | + contents: read |
| 128 | + packages: read |
| 129 | + strategy: |
| 130 | + fail-fast: false |
| 131 | + matrix: |
| 132 | + variant: [pinned, rolling] |
| 133 | + steps: |
| 134 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 135 | + with: |
| 136 | + persist-credentials: false |
| 137 | + |
| 138 | + - uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 |
| 139 | + with: |
| 140 | + registry: ${{ env.REGISTRY }} |
| 141 | + username: ${{ github.actor }} |
| 142 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 143 | + |
| 144 | + - name: Start the stack |
| 145 | + run: | |
| 146 | + set -euo pipefail |
| 147 | + cp .env.example .env |
| 148 | + { |
| 149 | + echo "MARIADB_ROOT_PASSWORD=smoke-test-only" |
| 150 | + echo "PMA_BLOWFISH_SECRET=smoketestsmoketestsmoketest12345" |
| 151 | + if [ "${{ matrix.variant }}" = "rolling" ]; then |
| 152 | + echo "PMA_IMAGE_TAG=latest-rolling" |
| 153 | + fi |
| 154 | + } >> .env |
| 155 | + docker compose --profile standalone up -d --wait --wait-timeout 300 |
| 156 | +
|
| 157 | + - name: phpMyAdmin answers and logs in |
| 158 | + run: | |
| 159 | + set -euo pipefail |
| 160 | + jar=$(mktemp) |
| 161 | + code=$(curl -sS -o /dev/null -w '%{http_code}' http://127.0.0.1:8080/) |
| 162 | + [ "$code" = "200" ] || { echo "::error::login page returned $code"; exit 1; } |
| 163 | +
|
| 164 | + token=$(curl -sS -c "$jar" http://127.0.0.1:8080/index.php \ |
| 165 | + | grep -oE 'name="token" value="[^"]+"' | head -1 | sed 's/.*value="//;s/"//') |
| 166 | + [ -n "$token" ] || { echo "::error::no CSRF token in the login form"; exit 1; } |
| 167 | +
|
| 168 | + curl -sS -b "$jar" -c "$jar" -o /dev/null \ |
| 169 | + -X POST -d "pma_username=root&pma_password=smoke-test-only&server=1&target=index.php&token=$token" \ |
| 170 | + http://127.0.0.1:8080/index.php |
| 171 | + # The authenticated page names the server it is connected to; a |
| 172 | + # failed login would render the form again instead. |
| 173 | + curl -sS -b "$jar" http://127.0.0.1:8080/index.php | grep -q 'db via TCP/IP' \ |
| 174 | + || { echo "::error::login did not reach the database"; exit 1; } |
| 175 | + echo "logged in against the database" |
| 176 | +
|
| 177 | + - name: php-fpm endpoints are not public |
| 178 | + run: | |
| 179 | + set -euo pipefail |
| 180 | + for path in ping status; do |
| 181 | + code=$(curl -sS -o /dev/null -w '%{http_code}' "http://127.0.0.1:8080/$path") |
| 182 | + [ "$code" = "403" ] || { echo "::error::/$path answered $code, expected 403"; exit 1; } |
| 183 | + done |
| 184 | +
|
| 185 | + - name: Logs on failure |
| 186 | + if: failure() |
| 187 | + run: docker compose --profile standalone logs |
0 commit comments