added image caching to workflows #19
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build kraken | |
| on: | |
| workflow_dispatch: | |
| push: | |
| tags: | |
| - 'v*' # match tags that start with v (like v1.0.0) | |
| branches: | |
| - dev | |
| - master | |
| paths: | |
| - '.github/workflows/kraken.yml' | |
| - 'kraken/**' | |
| jobs: | |
| build-docker: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| packages: write # to be able to publish docker images | |
| steps: | |
| - uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| # docker image build | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to GHCR registry | |
| run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin | |
| - name: build and push kraken | |
| working-directory: ./kraken | |
| run: | | |
| REGISTRY="ghcr.io/${{ github.repository }}/kraken" | |
| GIT_TAG=$(git describe --tags 2>/dev/null || echo "develop") | |
| GIT_BRANCH=${GITHUB_REF#refs/heads/} | |
| GIT_TAG_IMAGE="${REGISTRY}:${GIT_TAG}" | |
| GIT_BRANCH_IMAGE="${REGISTRY}:${GIT_BRANCH}" | |
| docker pull ${GIT_TAG_IMAGE} || true | |
| docker pull ${GIT_BRANCH_IMAGE} || true | |
| docker build \ | |
| -t ${GIT_TAG_IMAGE} \ | |
| -t ${GIT_BRANCH_IMAGE} . | |
| if [[ ! -z "$GIT_TAG" && "$GIT_TAG" == v* ]]; then | |
| docker push ${GIT_TAG_IMAGE} | |
| fi | |
| if [ ! -z "$GIT_BRANCH" ]; then | |
| docker push ${GIT_BRANCH_IMAGE} | |
| fi |