Skip to content

Add caching + don't push :latest tag on feature branches #45

Add caching + don't push :latest tag on feature branches

Add caching + don't push :latest tag on feature branches #45

name: docker-build-and-push
# Disabled in favour of faster Depot builds
# on: push
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: docker.io/reclaimthestack/rails-example
flavor: latest=true
tags: type=sha,format=long
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}