|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + |
| 8 | +env: |
| 9 | + REGISTRY: ghcr.io |
| 10 | + PLATFORM: linux/amd64,linux/arm64 |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + permissions: |
| 16 | + contents: read |
| 17 | + packages: write |
| 18 | + attestations: write |
| 19 | + strategy: |
| 20 | + matrix: |
| 21 | + php_version: |
| 22 | + - 8.2 |
| 23 | + - 8.3 |
| 24 | + - 8.4 |
| 25 | + steps: |
| 26 | + - name: Set up QEMU |
| 27 | + uses: docker/setup-qemu-action@v3 |
| 28 | + - name: Set up Docker Buildx |
| 29 | + uses: docker/setup-buildx-action@v3 |
| 30 | + with: |
| 31 | + platforms: ${{ env.PLATFORM }} |
| 32 | + |
| 33 | + - name: Login to Docker Hub |
| 34 | + uses: docker/login-action@v3 |
| 35 | + with: |
| 36 | + registry: ${{ env.REGISTRY }} |
| 37 | + username: ${{ github.actor }} |
| 38 | + password: ${{ github.token }} |
| 39 | + |
| 40 | + - uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Extract metadata (tags, labels) for Docker |
| 43 | + id: meta |
| 44 | + uses: docker/metadata-action@v5 |
| 45 | + with: |
| 46 | + labels: | |
| 47 | + org.opencontainers.image.title="php-devcontainer" |
| 48 | + org.opencontainers.image.vendor="act coding GbR" |
| 49 | + org.opencontainers.image.version="${{ matrix.php_version }}" |
| 50 | + tags: | |
| 51 | + type=raw,${{ matrix.php_version }} |
| 52 | + flavor: | |
| 53 | + latest=false |
| 54 | +
|
| 55 | + - name: Build and push |
| 56 | + uses: docker/build-push-action@v6 |
| 57 | + id: push |
| 58 | + with: |
| 59 | + context: src |
| 60 | + file: src/Dockerfile |
| 61 | + tags: ${{ env.REGISTRY }}/${{ github.repository }} |
| 62 | + labels: ${{ steps.meta.outputs.labels }} |
| 63 | + push: ${{ github.event_name != 'pull_request' }} |
| 64 | + cache-from: type=gha |
| 65 | + cache-to: type=gha,mode=max |
| 66 | + platforms: ${{ env.PLATFORM }} |
| 67 | + build-args: | |
| 68 | + PHP_VERSION=${{ matrix.php_version }} |
| 69 | +
|
| 70 | + - name: Generate artifact attestation |
| 71 | + uses: actions/attest-build-provenance@v2 |
| 72 | + if: github.event_name != 'pull_request' |
| 73 | + with: |
| 74 | + subject-name: ${{ env.REGISTRY }}/${{ github.repository }} |
| 75 | + subject-digest: ${{ steps.push.outputs.digest }} |
| 76 | + push-to-registry: true |
0 commit comments