ci: Use cosign to sign container images. #46
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: Create and publish a api image | |
on: push | |
env: | |
REGISTRY: ghcr.io/metal-toolbox | |
APP_IMAGE_NAME: audito-maldito/audito-maldito | |
jobs: | |
auto-release: | |
name: Create Release | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
generate_release_notes: true | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
id-token: write # needed for signing the images with GitHub OIDC Token | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@1f401f745bf57e30b3a2800ad308a87d2ebdf14b | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- uses: sigstore/[email protected] | |
with: | |
cosign-release: "v2.2.1" | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date -u +'%Y-%m-%dT%H:%M:%SZ')" | |
- name: Extract am metadata (tags, labels) for Docker | |
id: am-metadata | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }} | |
- name: Extract rsyslog metadata (tags, labels) for Docker | |
id: rsyslog-metadata | |
uses: docker/[email protected] | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}-rsyslog | |
- name: Build rsyslog and push Docker image | |
id: rsyslog-build-push | |
uses: docker/[email protected] | |
with: | |
context: "./contrib/rsyslog" | |
push: true | |
file: ./contrib/rsyslog/Dockerfile.ubuntu | |
tags: ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}:${{ github.ref_name }}-rsyslog | |
labels: ${{ steps.am-metadata.outputs.labels }} | |
- run: cosign sign -y -r "${TAGS}@${DIGEST}" | |
env: | |
DIGEST: ${{ steps.rsyslog-build-push.outputs.digest }} | |
TAGS: ${{ steps.rsyslog-metadata.outputs.tags }} | |
- name: Build and push Docker image | |
id: am-build-push | |
uses: docker/[email protected] | |
with: | |
push: true | |
file: Dockerfile | |
tags: ${{ env.REGISTRY }}/${{ env.APP_IMAGE_NAME }}:${{ github.ref_name }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
- run: cosign sign -y -r "${TAGS}@${DIGEST}" | |
env: | |
DIGEST: ${{ steps.am-build-push.outputs.digest }} | |
TAGS: ${{ steps.am-metadata.outputs.tags }} |