Skip to content

Reworked docker-publish.yml #42

Reworked docker-publish.yml

Reworked docker-publish.yml #42

name: Docker
# Specifies the trigger for this workflow.
# docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
on:
push:
branches: ["production"]
# Setting the default enviroment
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- dockerfile: ./bot/Dockerfile
image_name: inf_upol_discord-bot
context: ./
- dockerfile: ./menza/Dockerfile
image_name: inf_upol_menza
context: ./menza
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install and setup the Cosign tool
# https://github.com/sigstore/cosign-installer
- name: Install Cosign
uses: sigstore/[email protected]
- name: Set up Docker Buildx
uses: docker/[email protected]
# Login against a Docker registry
# https://github.com/docker/login-action
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}/${{ matrix.image_name }}
# Build and push Docker image with Buildx
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ${{ matrix.context }}
file: ${{ matrix.dockerfile }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
# Sigh the image
# https://github.com/sigstore/cosign-installer
- name: Sign the images with GitHub OIDC Token
env:
DIGEST: ${{ steps.build-and-push.outputs.digest }}
TAGS: ${{ steps.meta.outputs.tags }}
run: cosign sign --yes "${TAGS}@${DIGEST}"