Use GitHub Actions Cache for image cache
This commit is contained in:
		
							parent
							
								
									4b7c1ac9f9
								
							
						
					
					
						commit
						482c7d7987
					
				
					 1 changed files with 42 additions and 24 deletions
				
			
		
							
								
								
									
										66
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										66
									
								
								.github/workflows/build.yml
									
										
									
									
										vendored
									
									
								
							| 
						 | 
					@ -20,6 +20,10 @@ jobs:
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
 | 
					      - name: Install buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v1
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          config: .github/buildkit.toml
 | 
				
			||||||
      - name: Login to Docker
 | 
					      - name: Login to Docker
 | 
				
			||||||
        uses: docker/login-action@v1
 | 
					        uses: docker/login-action@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
| 
						 | 
					@ -29,12 +33,17 @@ jobs:
 | 
				
			||||||
      - name: Image Name
 | 
					      - name: Image Name
 | 
				
			||||||
        id: imagename
 | 
					        id: imagename
 | 
				
			||||||
        run: echo "::set-output name=name::ghcr.io/${GITHUB_REPOSITORY,,}/base:latest"
 | 
					        run: echo "::set-output name=name::ghcr.io/${GITHUB_REPOSITORY,,}/base:latest"
 | 
				
			||||||
      - name: Build base image
 | 
					      - name: Stop Commands
 | 
				
			||||||
        run: |
 | 
					        run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
				
			||||||
          T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
					      - name: Build target base image
 | 
				
			||||||
          docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from ${{ steps.imagename.outputs.name }} --tag ${{ steps.imagename.outputs.name }} images/base
 | 
					        uses: docker/build-push-action@v2
 | 
				
			||||||
      - name: Push base image
 | 
					        with:
 | 
				
			||||||
        run: docker push ${{ steps.imagename.outputs.name }}
 | 
					          context: images/base
 | 
				
			||||||
 | 
					          pull: true
 | 
				
			||||||
 | 
					          push: true
 | 
				
			||||||
 | 
					          tags: ${{ steps.imagename.outputs.name }}
 | 
				
			||||||
 | 
					          cache-to: type=gha,mode=max
 | 
				
			||||||
 | 
					          cache-from: type=gha
 | 
				
			||||||
  build_target_bases:
 | 
					  build_target_bases:
 | 
				
			||||||
    name: Build target base image
 | 
					    name: Build target base image
 | 
				
			||||||
    needs: build_base
 | 
					    needs: build_base
 | 
				
			||||||
| 
						 | 
					@ -46,6 +55,10 @@ jobs:
 | 
				
			||||||
    steps:
 | 
					    steps:
 | 
				
			||||||
      - name: Checkout
 | 
					      - name: Checkout
 | 
				
			||||||
        uses: actions/checkout@v2
 | 
					        uses: actions/checkout@v2
 | 
				
			||||||
 | 
					      - name: Install buildx
 | 
				
			||||||
 | 
					        uses: docker/setup-buildx-action@v1
 | 
				
			||||||
 | 
					        with:
 | 
				
			||||||
 | 
					          config: .github/buildkit.toml
 | 
				
			||||||
      - name: Login to Docker
 | 
					      - name: Login to Docker
 | 
				
			||||||
        uses: docker/login-action@v1
 | 
					        uses: docker/login-action@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
| 
						 | 
					@ -55,12 +68,17 @@ jobs:
 | 
				
			||||||
      - name: Image Name
 | 
					      - name: Image Name
 | 
				
			||||||
        id: imagename
 | 
					        id: imagename
 | 
				
			||||||
        run: echo "::set-output name=name::ghcr.io/${GITHUB_REPOSITORY,,}/base-${{ matrix.target }}:latest"
 | 
					        run: echo "::set-output name=name::ghcr.io/${GITHUB_REPOSITORY,,}/base-${{ matrix.target }}:latest"
 | 
				
			||||||
 | 
					      - name: Stop Commands
 | 
				
			||||||
 | 
					        run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
				
			||||||
      - name: Build target base image
 | 
					      - name: Build target base image
 | 
				
			||||||
        run: |
 | 
					        uses: docker/build-push-action@v2
 | 
				
			||||||
          T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
					        with:
 | 
				
			||||||
          docker build --pull --build-arg BUILDKIT_INLINE_CACHE=1 --build-arg GH_REPO=${GITHUB_REPOSITORY,,} --cache-from ${{ steps.imagename.outputs.name }} --tag ${{ steps.imagename.outputs.name }} images/base-${{ matrix.target }}
 | 
					          context: images/base-${{ matrix.target }}
 | 
				
			||||||
      - name: Push target base image
 | 
					          pull: true
 | 
				
			||||||
        run: docker push ${{ steps.imagename.outputs.name }}
 | 
					          push: true
 | 
				
			||||||
 | 
					          tags: ${{ steps.imagename.outputs.name }}
 | 
				
			||||||
 | 
					          cache-to: type=gha,mode=max
 | 
				
			||||||
 | 
					          cache-from: type=gha
 | 
				
			||||||
  build_targets:
 | 
					  build_targets:
 | 
				
			||||||
    name: Build target-variant image
 | 
					    name: Build target-variant image
 | 
				
			||||||
    needs: build_target_bases
 | 
					    needs: build_target_bases
 | 
				
			||||||
| 
						 | 
					@ -77,30 +95,30 @@ jobs:
 | 
				
			||||||
        uses: docker/setup-buildx-action@v1
 | 
					        uses: docker/setup-buildx-action@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          config: .github/buildkit.toml
 | 
					          config: .github/buildkit.toml
 | 
				
			||||||
      - name: Generate Dockerfile
 | 
					 | 
				
			||||||
        run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
 | 
					 | 
				
			||||||
      - name: Login to Docker
 | 
					      - name: Login to Docker
 | 
				
			||||||
        uses: docker/login-action@v1
 | 
					        uses: docker/login-action@v1
 | 
				
			||||||
        with:
 | 
					        with:
 | 
				
			||||||
          registry: ghcr.io
 | 
					          registry: ghcr.io
 | 
				
			||||||
          username: ${{ github.actor }}
 | 
					          username: ${{ github.actor }}
 | 
				
			||||||
          password: ${{ github.token }}
 | 
					          password: ${{ github.token }}
 | 
				
			||||||
 | 
					      - name: Generate Dockerfile
 | 
				
			||||||
 | 
					        run: ./generate.sh ${{ matrix.target }} ${{ matrix.variant }}
 | 
				
			||||||
      - name: Image Name
 | 
					      - name: Image Name
 | 
				
			||||||
        id: imagename
 | 
					        id: imagename
 | 
				
			||||||
        run: |
 | 
					        run: |
 | 
				
			||||||
          IMG="ghcr.io/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
 | 
					          IMG="ghcr.io/${GITHUB_REPOSITORY,,}/${{ matrix.target }}-${{ matrix.variant }}"
 | 
				
			||||||
          echo "::set-output name=name::${IMG/ /-}:latest"
 | 
					          echo "::set-output name=name::${IMG/ /-}:latest"
 | 
				
			||||||
          echo "::set-output name=cache_name::${IMG/ /-}:cache"
 | 
					      - name: Stop Commands
 | 
				
			||||||
      - name: Build variant image
 | 
					        run: T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
				
			||||||
        run: |
 | 
					      - name: Build target base image
 | 
				
			||||||
          T="$(echo -n ${{ github.token }} | sha256sum | head -c 64)" && echo -e "::add-mask::${T}\n::stop-commands::${T}"
 | 
					        uses: docker/build-push-action@v2
 | 
				
			||||||
          docker buildx build \
 | 
					        with:
 | 
				
			||||||
            --pull \
 | 
					          context: .
 | 
				
			||||||
            --tag ${{ steps.imagename.outputs.name }} \
 | 
					          pull: true
 | 
				
			||||||
            --cache-to=type=registry,mode=max,ref=${{ steps.imagename.outputs.cache_name }} \
 | 
					          push: true
 | 
				
			||||||
            --cache-from=type=registry,ref=${{ steps.imagename.outputs.cache_name }} \
 | 
					          tags: ${{ steps.imagename.outputs.name }}
 | 
				
			||||||
            --output=type=image,push=true,name=${{ steps.imagename.outputs.name }} \
 | 
					          cache-to: type=gha,mode=max
 | 
				
			||||||
            .
 | 
					          cache-from: type=gha
 | 
				
			||||||
  build_ffmpeg:
 | 
					  build_ffmpeg:
 | 
				
			||||||
    name: Build ffmpeg
 | 
					    name: Build ffmpeg
 | 
				
			||||||
    needs: build_targets
 | 
					    needs: build_targets
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue