CI: cache Docker layers 💚

db-rest equivalent of c8a06f0c6d
This commit is contained in:
Jannis R 2023-04-20 00:33:18 +02:00
parent 63964f91f3
commit a5688cabe6
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5

View file

@ -26,23 +26,28 @@ jobs:
steps: steps:
- name: check out the repo - name: check out the repo
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: configure Docker to use buildx
uses: docker/setup-buildx-action@v2
- name: log in to Docker Hub - name: log in to Docker Hub
uses: docker/login-action@v1 uses: docker/login-action@v2
with: with:
username: ${{ secrets.DOCKER_USERNAME }} username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_ACCESS_TOKEN }} password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
- name: build Docker image & push to Docker Hub - name: build Docker image & push to Docker Hub
uses: docker/build-push-action@v3 uses: docker/build-push-action@v4
with: with:
context: . context: .
push: true push: true
tags: | tags: |
derhuerst/db-rest:6 derhuerst/db-rest:6
derhuerst/db-rest:latest derhuerst/db-rest:latest
# https://docs.docker.com/build/ci/github-actions/examples/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd
# this is for the public-transport/infrastructure cluster # this is for the public-transport/infrastructure cluster
- name: log in to GitHub Container Registry - name: log in to GitHub Container Registry
uses: docker/login-action@v1 uses: docker/login-action@v2
with: with:
registry: ghcr.io registry: ghcr.io
username: ${{ github.repository_owner }} username: ${{ github.repository_owner }}
@ -54,8 +59,11 @@ jobs:
id: datetime id: datetime
run: echo "::set-output name=datetime::$(date -u +'%Y-%m-%dT%H.%M.%SZ')" run: echo "::set-output name=datetime::$(date -u +'%Y-%m-%dT%H.%M.%SZ')"
- name: push Docker image to GitHub Registry - name: push Docker image to GitHub Registry
uses: docker/build-push-action@v3 uses: docker/build-push-action@v4
with: with:
context: . context: .
push: true push: true
tags: ghcr.io/${{github.repository}}:v6_${{steps.hash.outputs.hash}}_${{steps.datetime.outputs.datetime}} tags: ghcr.io/${{github.repository}}:v6_${{steps.hash.outputs.hash}}_${{steps.datetime.outputs.datetime}}
# https://docs.docker.com/build/ci/github-actions/examples/#github-cache
cache-from: type=gha
cache-to: type=gha,mode=max,oci-mediatypes=true,compression=zstd