|
@@ -0,0 +1,93 @@
|
|
|
+name: Build and push Docker image (latest)
|
|
|
+on:
|
|
|
+ push:
|
|
|
+ branches:
|
|
|
+ - main
|
|
|
+ tags:
|
|
|
+ - v*
|
|
|
+jobs:
|
|
|
+ docker-tests:
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v3
|
|
|
+ with:
|
|
|
+ submodules: recursive
|
|
|
+
|
|
|
+ - name: Set up Docker Buildx
|
|
|
+ id: buildx
|
|
|
+ uses: docker/setup-buildx-action@master
|
|
|
+ with:
|
|
|
+ install: true
|
|
|
+
|
|
|
+ - name: Build test image
|
|
|
+ uses: docker/build-push-action@v3
|
|
|
+ with:
|
|
|
+ context: ./
|
|
|
+ file: Dockerfile
|
|
|
+ push: false
|
|
|
+ pull: true
|
|
|
+ target: builder
|
|
|
+ tags: ${{secrets.REGISTRY_LOGIN_SERVER}}/${{ secrets.REGISTRY_USERNAME }}/frankenphp:${{ github.sha }}-builder
|
|
|
+ builder: ${{ steps.buildx.outputs.name }}
|
|
|
+ cache-from: type=gha
|
|
|
+ cache-to: type=gha,mode=max
|
|
|
+ outputs: type=docker,dest=/tmp/.builder.tar
|
|
|
+
|
|
|
+ - name: Run tests
|
|
|
+ run: |
|
|
|
+ docker load -i /tmp/.builder.tar
|
|
|
+ docker run --rm ${{secrets.REGISTRY_LOGIN_SERVER}}/${{ secrets.REGISTRY_USERNAME }}/frankenphp:${{ github.sha }}-builder "go test"
|
|
|
+ push-image:
|
|
|
+ runs-on: ubuntu-latest
|
|
|
+ steps:
|
|
|
+ - uses: actions/checkout@v3
|
|
|
+ with:
|
|
|
+ submodules: recursive
|
|
|
+
|
|
|
+ - name: Docker Login
|
|
|
+ uses: docker/login-action@v2
|
|
|
+ with:
|
|
|
+ registry: ${{secrets.REGISTRY_LOGIN_SERVER}}
|
|
|
+ username: ${{secrets.REGISTRY_USERNAME}}
|
|
|
+ password: ${{secrets.REGISTRY_PASSWORD}}
|
|
|
+
|
|
|
+ - name: Docker meta
|
|
|
+ id: meta
|
|
|
+ uses: docker/metadata-action@v4
|
|
|
+ with:
|
|
|
+ # list of Docker images to use as base name for tags
|
|
|
+ images: |
|
|
|
+ ${{ secrets.REGISTRY_LOGIN_SERVER }}/${{ secrets.REGISTRY_REPO }}/frankenphp
|
|
|
+ # generate Docker tags based on the following events/attributes
|
|
|
+ tags: |
|
|
|
+ type=schedule
|
|
|
+ type=ref,event=branch
|
|
|
+ type=ref,event=pr
|
|
|
+ type=semver,pattern={{version}}
|
|
|
+ type=semver,pattern={{major}}.{{minor}}
|
|
|
+ type=semver,pattern={{major}}
|
|
|
+ type=sha
|
|
|
+
|
|
|
+ - name: Set up Docker Buildx
|
|
|
+ id: buildx
|
|
|
+ uses: docker/setup-buildx-action@master
|
|
|
+ with:
|
|
|
+ install: true
|
|
|
+
|
|
|
+ - name: Setup QEMU
|
|
|
+ uses: docker/setup-qemu-action@v2
|
|
|
+
|
|
|
+ - name: Build and Push Image
|
|
|
+ uses: docker/build-push-action@v3
|
|
|
+ with:
|
|
|
+ context: ./
|
|
|
+ file: Dockerfile
|
|
|
+ push: true
|
|
|
+ pull: true
|
|
|
+ target: final
|
|
|
+ platforms: linux/amd64,linux/arm64
|
|
|
+ tags: ${{ steps.meta.outputs.tags }}
|
|
|
+ labels: ${{ steps.meta.outputs.labels }}
|
|
|
+ builder: ${{ steps.buildx.outputs.name }}
|
|
|
+ cache-from: type=gha
|
|
|
+ cache-to: type=gha,mode=max
|