Skip to content

Development

Development #1

name: Push Docker image to Container Registry
on:
pull_request:
types:
- closed
branches:
- main
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
context: workflow
images: ${{ vars.REGISTRY }}/${{ vars.DOCKER_NAMESPACE }}/dotfiles
tags: |
type=ref,event=branch
type=ref,event=tag
type=sha,prefix=git-
type=raw,value=latest
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
- name: Extract metadata for Docker cache
id: cache-meta
uses: docker/metadata-action@v5
with:
images: ${{ vars.REGISTRY }}/${{ vars.DOCKER_NAMESPACE }}/dotfiles
tags: |
type=ref,event=branch
flavor: |
prefix=cache-
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ vars.REGISTRY }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: test
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=registry,ref=${{ steps.cache-meta.outputs.tags }}
cache-to: type=registry,ref=${{ steps.cache-meta.outputs.tags }},mode=max
build-args: |
BUILD_HASH=${{ github.sha }}