Skip to content

Commit

Permalink
Fix and improve CI action to build and publish Docker images
Browse files Browse the repository at this point in the history
  • Loading branch information
amotl committed Apr 30, 2021
1 parent 314cd67 commit f104f0f
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -10,6 +14,9 @@ on:
tags:
- '*.*.*'

env:
GHCR_IMAGE_NAME: crate/cratedb-prometheus-adapter

jobs:
docker:
runs-on: ubuntu-latest
Expand All @@ -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
Expand All @@ -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: |
Expand All @@ -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
Expand All @@ -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

0 comments on commit f104f0f

Please sign in to comment.