Skip to content

Workflow file for this run

name: Container Image Build and Sign
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
release:
types: [published]
env:
IMAGE_NAME: soubinan/ignition-server
TEST_TAG: soubinan/ignition-server:test
PROJECT_URL: https://github.com/soubinan/ignition-server
AUTHOR: https://github.com/soubinan
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,latest
labels: |
org.opencontainers.image.source=${{ env.PROJECT_URL }}
org.opencontainers.image.url=${{ env.PROJECT_URL }}
org.opencontainers.image.title=Ignition-Server
org.opencontainers.image.description=Ignition as a service
org.opencontainers.image.authors=${{ env.AUTHOR }}
org.opencontainers.image.licenses=CC-BY-SA-4.0
- name: Install cosign
if: github.event_name == 'release'
uses: sigstore/cosign-installer@v3
with:
cosign-release: main
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GHP }}
if: github.event_name == 'release'
- name: Build and push
id: build-and-push
uses: docker/build-push-action@v5
with:
context: "."
file: "./Containerfile"
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
push: ${{ github.event_name == 'release' }}
- name: Sign the published container images
if: github.event_name == 'release'
run: |
cosign sign --yes --key env://COSIGN_PRIVATE_KEY "${TAGS}@${DIGEST}"
env:
TAGS: ${{ steps.meta.outputs.tags }}
DIGEST: ${{ steps.build-and-push.outputs.digest }}
COSIGN_PRIVATE_KEY: ${{ secrets.COSIGN_PRIVATE_KEY }}
COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}