Skip to content

Build and Push Docker Images #2

Build and Push Docker Images

Build and Push Docker Images #2

Workflow file for this run

name: Build and Push Docker Images
on:
workflow_dispatch:
inputs:
image:
required: true
description: Image à construire
type: choice
options:
- calidum-rotae-service
- discord-provider
- email-provider
tag:
required: true
description: Version pour tagger l'image
env:
REGISTRY: ghcr.io/clubcedille
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Check Out Repo
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache-${{ github.event.inputs.image }}
key: ${{ runner.os }}-buildx-${{ github.sha }}-${{ github.event.inputs.image }}
restore-keys: ${{ runner.os }}-buildx-${{ github.event.inputs.image }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ./cmd/${{ github.event.inputs.image }}
file: ./cmd/${{ github.event.inputs.image }}/Dockerfile
push: true
tags: |
${{ env.REGISTRY }}/${{ github.event.inputs.image }}:${{ github.event.inputs.tag }}
${{ env.REGISTRY }}/${{ github.event.inputs.image }}:latest
cache-from: type=local,src=/tmp/.buildx-cache-${{ github.event.inputs.image }}
cache-to: type=local,mode=max,dest=/tmp/.buildx-cache-${{ github.event.inputs.image }}-new
- name: Refresh Cache
run: |
rm -rf /tmp/.buildx-cache-${{ github.event.inputs.image }}
mv /tmp/.buildx-cache-${{ github.event.inputs.image }}-new /tmp/.buildx-cache-${{ github.event.inputs.image }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}