|
8 | 8 | IMAGE_NAME: ${{ github.repository }} |
9 | 9 |
|
10 | 10 |
|
| 11 | +concurrency: |
| 12 | + group: push-to-registry-${{ github.head_ref || github.run_id }} |
| 13 | + cancel-in-progress: true |
| 14 | + |
11 | 15 | jobs: |
12 | | - build: |
| 16 | + push_to_registry: |
| 17 | + name: Build image |
13 | 18 | runs-on: ubuntu-latest |
14 | | - |
| 19 | + strategy: |
| 20 | + fail-fast: false |
| 21 | + matrix: |
| 22 | + image_type: [apache,fpm] |
| 23 | + permissions: |
| 24 | + packages: write |
| 25 | + contents: read |
15 | 26 | steps: |
16 | | - - name: Checkout code |
17 | | - uses: actions/checkout@v4 |
18 | | - |
19 | | - - name: Log in to GitHub Container Registry |
20 | | - run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin |
21 | | - |
22 | | - - name: Build Docker APP image |
23 | | - run: docker build . -t ghcr.io/librecodecoop/nextcloud-app:31-fpm-latest -f .docker/app/Dockerfile |
24 | | - |
25 | | - - name: Build Docker WEB image |
26 | | - run: docker build . -t ghcr.io/librecodecoop/nextcloud-web:31-fpm-latest -f .docker/web/Dockerfile |
27 | | - |
28 | | - |
29 | | - - name: Push Docker APP image |
30 | | - run: docker push ghcr.io/librecodecoop/nextcloud-app:31-fpm-latest |
31 | | - |
32 | | - - name: Push Docker WEB image |
33 | | - run: docker push ghcr.io/librecodecoop/nextcloud-web:31-fpm-latest |
| 27 | + - name: Check out the repo |
| 28 | + uses: actions/checkout@v4 |
| 29 | + - name: Docker meta |
| 30 | + uses: docker/metadata-action@v5 |
| 31 | + id: meta |
| 32 | + with: |
| 33 | + # list of Docker images to use as base name for tags |
| 34 | + images: | |
| 35 | + ghcr.io/librecodecoop/nextcloud-docker |
| 36 | + # generate Docker tags based on the following events/attributes |
| 37 | + tags: | |
| 38 | + type=semver,pattern={{version}},value=${{ inputs.mautic_version }} |
| 39 | + type=semver,pattern={{major}}.{{minor}},value=${{ inputs.mautic_version }},enable=${{ inputs.overwrite_latest_minor }} |
| 40 | + type=semver,pattern={{major}},value=${{ inputs.mautic_version }},enable=${{ inputs.overwrite_latest_major }} |
| 41 | + type=raw,value=latest,enable=${{ inputs.tag_as_latest && matrix.image_type == 'apache' }},suffix= |
| 42 | + flavor: | |
| 43 | + latest=false |
| 44 | + prefix= |
| 45 | + suffix=-${{ matrix.image_type }} |
| 46 | + - name: Set up QEMU |
| 47 | + uses: docker/setup-qemu-action@v3 |
| 48 | + - name: Set up Docker Buildx |
| 49 | + uses: docker/setup-buildx-action@v3 |
| 50 | + - name: Cache Docker layers |
| 51 | + uses: actions/cache@v4 |
| 52 | + with: |
| 53 | + path: /tmp/.buildx-cache |
| 54 | + key: ${{ matrix.container }}-buildx-${{ github.sha }} |
| 55 | + restore-keys: | |
| 56 | + ${{ matrix.container }}-buildx- |
| 57 | + - name: Log in to GitHub Container Registry |
| 58 | + uses: docker/login-action@v3 |
| 59 | + with: |
| 60 | + registry: ghcr.io |
| 61 | + username: ${{ github.actor }} |
| 62 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 63 | + - name: Build container image |
| 64 | + uses: docker/build-push-action@v6 |
| 65 | + with: |
| 66 | + push: false |
| 67 | + context: .docker |
| 68 | + platforms: linux/amd64,linux/arm64 |
| 69 | + file: .docker/Dockerfile.${{ matrix.image_type }} |
| 70 | + tags: ${{ steps.meta.outputs.tags }} |
| 71 | + build-args: | |
| 72 | + MAUTIC_VERSION=${{ inputs.mautic_version }} |
| 73 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 74 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 75 | + - name: Push container image |
| 76 | + uses: docker/build-push-action@v6 |
| 77 | + if: github.ref == 'refs/heads/main' || inputs.publish |
| 78 | + with: |
| 79 | + push: true |
| 80 | + context: .docker |
| 81 | + platforms: linux/amd64,linux/arm64 |
| 82 | + file: .docker/Dockerfile.${{ matrix.image_type }} |
| 83 | + tags: ${{ steps.meta.outputs.tags }} |
| 84 | + cache-from: type=local,src=/tmp/.buildx-cache |
| 85 | + cache-to: type=local,dest=/tmp/.buildx-cache-new |
| 86 | + - name: Move cache |
| 87 | + run: | |
| 88 | + rm -rf /tmp/.buildx-cache |
| 89 | + mv /tmp/.buildx-cache-new /tmp/.buildx-cache |
0 commit comments