Merge branch 'main' of github.com:sogelink-research/ctod #81
Workflow file for this run
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: Build and Push Docker Image | |
on: | |
push: | |
branches: [ "main" ] | |
tags: [ 'v*.*.*' ] | |
pull_request: | |
branches: [ "main" ] | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install cosign | |
if: github.event_name != 'pull_request' | |
uses: sigstore/cosign-installer@59acb6260d9c0ba8f4a2f9d9b48431a222b68e20 #v3.5.0 | |
with: | |
cosign-release: 'v2.2.4' | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Log into registry ${{ env.REGISTRY }} | |
if: github.event_name != 'pull_request' | |
uses: docker/[email protected] | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract Docker metadata for tags | |
id: meta-tags | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=ref,event=tag,pattern={{version}} | |
type=raw,value=latest | |
- name: Extract Docker metadata for branches | |
id: meta-branches | |
if: github.ref == 'refs/heads/main' | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=latest | |
- name: Build and push Docker image for tags | |
id: build-and-push-tags | |
if: startsWith(github.ref, 'refs/tags/') | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta-tags.outputs.tags }} | |
labels: ${{ steps.meta-tags.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
- name: Build and push Docker image for branches | |
id: build-and-push-branches | |
if: github.ref == 'refs/heads/main' | |
uses: docker/[email protected] | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta-branches.outputs.tags }} | |
labels: ${{ steps.meta-branches.outputs.labels }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |