Merge remote-tracking branch 'upstream/master' #7
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
name: docker | |
on: | |
push: | |
branches: | |
- "master" | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
# Docker BuildX caching borrowed from this tutorial; | |
# https://evilmartians.com/chronicles/build-images-on-github-actions-with-docker-layer-caching | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# This is the a separate action that sets up buildx runner | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
# So now you can use Actions' own caching! | |
- 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: Log in to ghcr | |
uses: docker/login-action@v1 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
# Add tags and labels to Docker image | |
# see docs here; https://github.com/docker/metadata-action | |
# OLD tags | |
# type=sha,prefix=,suffix=,format=short | |
# type=raw,value={{date 'YYYY.MM.DD'}}-${{ github.run_number % 10 }} | |
- name: Docker Metadata | |
id: meta | |
uses: docker/metadata-action@v3 | |
with: | |
images: ${{ env.REGISTRY }}/arrowtail-precision/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value={{date 'YYYY.MDD'}}.${{ github.run_number }} | |
# And make it available for the builds | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: true | |
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 | |
# This ugly bit is necessary if you don't want your cache to grow forever | |
# till it hits GitHub's limit of 5GB. | |
# Temp fix | |
# https://github.com/docker/build-push-action/issues/252 | |
# https://github.com/moby/buildkit/issues/1896 | |
- name: Move cache | |
run: | | |
rm -rf /tmp/.buildx-cache | |
mv /tmp/.buildx-cache-new /tmp/.buildx-cache |