Created
May 4, 2020 14:34
-
-
Save alvistar/5a5d241bf79893cf518884bf66cb9a5d to your computer and use it in GitHub Desktop.
Buildx cache example for Github Actions
This file contains 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
jobs: | |
build-docker: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: install buildx | |
uses: crazy-max/ghaction-docker-buildx@v1 | |
with: | |
buildx-version: latest | |
qemu-version: latest | |
- name: docker login | |
env: | |
USERNAME: ${{ secrets.DOCKER_USERNAME }} | |
PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
run: | | |
docker login -p $PASSWORD -u $USERNAME your-registry.com | |
- name: cache docker cache | |
uses: actions/cache@v1 | |
with: | |
path: ${{ github.workspace }}/cache | |
key: ${{ runner.os }}-docker-${{ hashfiles('cache/**') }} | |
restore-keys: | | |
${{ runner.os }}-docker- | |
- name: build docker image | |
run: > | |
docker buildx build | |
--cache-from "type=local,src=$GITHUB_WORKSPACE/cache" | |
--cache-to "type=local,dest=$GITHUB_WORKSPACE/cache" | |
--output "type=image, name=your_image:CI,push=false" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment