|
| 1 | +name: PHP 7.4 with MariaDB |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + paths: |
| 7 | + - "base/php/**" |
| 8 | + - "base/php-mariadb/**" |
| 9 | + - ".github/workflows/base.php-7.4-mariadb.yml" |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +env: |
| 13 | + REGISTRY: ghcr.io |
| 14 | + NAME: php-mariadb |
| 15 | + TAG: 7.4-alpine |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-push-image: |
| 19 | + runs-on: ubuntu-latest |
| 20 | + permissions: |
| 21 | + contents: read |
| 22 | + packages: write |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout repository |
| 26 | + uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Log in to the Container registry |
| 29 | + uses: docker/login-action@v3 |
| 30 | + with: |
| 31 | + registry: ${{ env.REGISTRY }} |
| 32 | + username: ${{ github.actor }} |
| 33 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 34 | + |
| 35 | + - name: Extract metadata (tags, labels) for Docker |
| 36 | + id: meta |
| 37 | + uses: docker/metadata-action@v5 |
| 38 | + with: |
| 39 | + images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ env.NAME }} |
| 40 | + tags: | |
| 41 | + ${{ env.TAG }} |
| 42 | +
|
| 43 | + - name: Build and push Docker image |
| 44 | + uses: docker/build-push-action@v5 |
| 45 | + with: |
| 46 | + context: base/${{ env.NAME }} |
| 47 | + file: base/${{ env.NAME }}/Dockerfile.7.4 |
| 48 | + tags: ${{ steps.meta.outputs.tags }} |
| 49 | + labels: ${{ steps.meta.outputs.labels }} |
| 50 | + push: true |
| 51 | + |
| 52 | + cleanup-images: |
| 53 | + runs-on: ubuntu-latest |
| 54 | + needs: build-and-push-image |
| 55 | + permissions: |
| 56 | + contents: read |
| 57 | + packages: write |
| 58 | + concurrency: |
| 59 | + group: cleanup-images-php-mariadb |
| 60 | + steps: |
| 61 | + - name: Get lower case repository name |
| 62 | + id: lower_repo |
| 63 | + run: | |
| 64 | + export REPO_NAME=${{ github.event.repository.name }} |
| 65 | + echo "repo_name=${REPO_NAME@L}" >> $GITHUB_OUTPUT |
| 66 | +
|
| 67 | + - name: Prune old packages |
| 68 | + uses: dataaxiom/ghcr-cleanup-action@v1 |
| 69 | + with: |
| 70 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + package: ${{ steps.lower_repo.outputs.repo_name }}/${{ env.NAME }} |
| 72 | + dry-run: false |
| 73 | + delete-untagged: true |
| 74 | + delete-ghost-images: true |
| 75 | + delete-partial-images: true |
0 commit comments