diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 87d97a1..830239a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,10 @@ +# Stage Docker images through GitHub Actions (GHA) to GitHub Container Registry (GHCR). +# +# Derived from: # https://github.com/docker/build-push-action/blob/master/docs/advanced/tags-labels.md # https://github.com/crazy-max/ghaction-docker-meta # https://github.com/docker/build-push-action +# https://github.com/MarcelCoding/luna/blob/main/.github/workflows/ci.yaml name: Release on: @@ -10,6 +14,9 @@ on: tags: - '*.*.*' +env: + GHCR_IMAGE_NAME: crate/cratedb-prometheus-adapter + jobs: docker: runs-on: ubuntu-latest @@ -24,8 +31,7 @@ jobs: with: # list of Docker images to use as base name for tags images: | - crate/cratedb-prometheus-adapter - ghcr.io/crate/cratedb-prometheus-adapter + ghcr.io/${{ env.GHCR_IMAGE_NAME }} # generate Docker tags based on the following events/attributes tags: | type=schedule,pattern=nightly @@ -38,9 +44,18 @@ jobs: - name: Set up QEMU uses: docker/setup-qemu-action@v1 + if: matrix.platforms != 'linux/amd64' - name: Set up Docker Buildx uses: docker/setup-buildx-action@v1 + - + name: Cache Docker layers + uses: actions/cache@v2 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-buildx- - name: Inspect builder run: | @@ -56,7 +71,7 @@ jobs: with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.GITHUB_TOKEN }} + password: ${{ github.token }} - name: Build and push uses: docker/build-push-action@v2 @@ -65,3 +80,11 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new + + - + name: Move cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache