|
| 1 | +name: Image Build |
| 2 | +on: |
| 3 | + workflow_call: |
| 4 | + |
| 5 | +jobs: |
| 6 | + build-image: |
| 7 | + name: Build and push Docker image |
| 8 | + runs-on: ubuntu-latest |
| 9 | + steps: |
| 10 | + - name: Checkout repository |
| 11 | + uses: actions/checkout@v5 |
| 12 | + with: |
| 13 | + ref: ${{ github.event.pull_request.head.sha }} |
| 14 | + |
| 15 | + - name: Docker meta |
| 16 | + id: meta |
| 17 | + uses: docker/metadata-action@v5 |
| 18 | + with: |
| 19 | + images: | |
| 20 | + digiblink/alpine-nginx-php-fpm |
| 21 | + ghcr.io/digiblink/alpine-nginx-php-fpm |
| 22 | + tags: | |
| 23 | + type=sha |
| 24 | + type=ref,event=tag |
| 25 | + type=raw,value=latest,enable={{is_default_branch}} |
| 26 | + flavor: | |
| 27 | + latest=auto |
| 28 | + prefix=,onlatest=false |
| 29 | + suffix= |
| 30 | + labels: | |
| 31 | + org.opencontainers.image.vendor=digiBlink |
| 32 | + org.opencontainers.image.source=https://github.com/${{ env.REPO_NAME }} |
| 33 | + org.opencontainers.image.title=Alpine based image with latest PHP 8.4 FPM and Nginx |
| 34 | + org.opencontainers.image.description=Alpine based image with latest PHP 8.4 FPM and Nginx |
| 35 | + org.opencontainers.image.created=${{ steps.time.outputs.time }} |
| 36 | + org.opencontainers.image.revision=${{ steps.short-sha.outputs.sha }} |
| 37 | +
|
| 38 | + - name: Set up QEMU |
| 39 | + uses: docker/setup-qemu-action@v3 |
| 40 | + |
| 41 | + - name: Set up Docker Buildx |
| 42 | + uses: docker/setup-buildx-action@v3 |
| 43 | + |
| 44 | + - name: Login to Docker Hub |
| 45 | + if: github.event_name != 'pull_request' |
| 46 | + uses: docker/login-action@v3 |
| 47 | + with: |
| 48 | + username: ${{ vars.DH_USER }} |
| 49 | + password: ${{ secrets.DH_PAT }} |
| 50 | + |
| 51 | + - name: Login to GHCR |
| 52 | + uses: docker/login-action@v3 |
| 53 | + with: |
| 54 | + registry: ghcr.io |
| 55 | + username: ${{ github.actor }} |
| 56 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + |
| 58 | + - name: Build image and push to GitHub Container Registry |
| 59 | + uses: docker/build-push-action@v6 |
| 60 | + with: |
| 61 | + push: ${{ github.event_name != 'pull_request' }} |
| 62 | + tags: ${{ steps.meta.outputs.tags }} |
| 63 | + labels: ${{ steps.meta.outputs.labels }} |
| 64 | + |
| 65 | + - name: Image digest |
| 66 | + run: echo ${{ steps.docker_build.outputs.digest }} |
0 commit comments