mirror of
https://github.com/optim-enterprises-bv/secureblue.git
synced 2025-11-08 14:23:38 +00:00
fix: update cosign action (#94)
This commit is contained in:
78
.github/workflows/build.yml
vendored
78
.github/workflows/build.yml
vendored
@@ -1,8 +1,6 @@
|
|||||||
name: build-ublue
|
name: build-ublue
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
|
||||||
- labeled
|
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths-ignore:
|
paths-ignore:
|
||||||
@@ -17,14 +15,13 @@ on:
|
|||||||
- '**.md'
|
- '**.md'
|
||||||
- '**.txt'
|
- '**.txt'
|
||||||
env:
|
env:
|
||||||
IMAGE_NAME: base
|
IMAGE_BASE_NAME: base
|
||||||
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
|
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
push-ghcr:
|
push-ghcr:
|
||||||
name: Build and push image
|
name: Build and push image
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ubuntu-22.04
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'ok-to-build') || github.event_name != 'pull_request'
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -32,36 +29,61 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
|
image_name: [silverblue]
|
||||||
major_version: [37]
|
major_version: [37]
|
||||||
include:
|
include:
|
||||||
- major_version: 37
|
- major_version: 37
|
||||||
is_latest: true
|
is_latest_version: true
|
||||||
is_stable: true
|
is_stable_version: true
|
||||||
steps:
|
steps:
|
||||||
# Checkout push-to-registry action GitHub repository
|
# Checkout push-to-registry action GitHub repository
|
||||||
- name: Checkout Push to Registry action
|
- name: Checkout Push to Registry action
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Matrix Variables
|
||||||
|
run: |
|
||||||
|
echo "IMAGE_NAME=${{ format('{0}-{1}', matrix.image_name, env.IMAGE_BASE_NAME) }}" >> $GITHUB_ENV
|
||||||
|
|
||||||
- name: Generate tags
|
- name: Generate tags
|
||||||
id: generate-tags
|
id: generate-tags
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
|
# Generate a timestamp for creating an image version history
|
||||||
alias_tags=()
|
TIMESTAMP="$(date +%Y%m%d)"
|
||||||
# Only perform the follow code when the action is spawned from a Pull Request
|
MAJOR_VERSION="${{ matrix.major_version }}"
|
||||||
|
COMMIT_TAGS=()
|
||||||
|
BUILD_TAGS=()
|
||||||
|
# Have tags for tracking builds during pull request
|
||||||
|
SHA_SHORT="$(git rev-parse --short HEAD)"
|
||||||
|
COMMIT_TAGS+=("pr-${{ github.event.number }}-${MAJOR_VERSION}")
|
||||||
|
COMMIT_TAGS+=("${SHA_SHORT}-${MAJOR_VERSION}")
|
||||||
|
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
|
||||||
|
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
|
||||||
|
COMMIT_TAGS+=("pr-${{ github.event.number }}")
|
||||||
|
COMMIT_TAGS+=("${SHA_SHORT}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
BUILD_TAGS=("${MAJOR_VERSION}" "${MAJOR_VERSION}-${TIMESTAMP}")
|
||||||
|
|
||||||
|
if [[ "${{ matrix.is_latest_version }}" == "true" ]] && \
|
||||||
|
[[ "${{ matrix.is_stable_version }}" == "true" ]]; then
|
||||||
|
BUILD_TAGS+=("${TIMESTAMP}")
|
||||||
|
BUILD_TAGS+=("latest")
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
|
||||||
alias_tags+=("pr-${{ github.event.number }}")
|
echo "Generated the following commit tags: "
|
||||||
|
for TAG in "${COMMIT_TAGS[@]}"; do
|
||||||
|
echo "${TAG}"
|
||||||
|
done
|
||||||
|
alias_tags=("${COMMIT_TAGS[@]}")
|
||||||
else
|
else
|
||||||
# The following is run when the timer is triggered or a merge/push to main
|
alias_tags=("${BUILD_TAGS[@]}")
|
||||||
echo "date=$(date +%Y%m%d)" >> $GITHUB_OUTPUT
|
|
||||||
alias_tags+=("${{ matrix.major_version }}")
|
|
||||||
if [[ "${{ matrix.is_latest }}" == "true" ]]; then
|
|
||||||
alias_tags+=("latest")
|
|
||||||
fi
|
|
||||||
if [[ "${{ matrix.is_stable }}" == "true" ]]; then
|
|
||||||
alias_tags+=("stable")
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
echo "Generated the following build tags: "
|
||||||
|
for TAG in "${BUILD_TAGS[@]}"; do
|
||||||
|
echo "${TAG}"
|
||||||
|
done
|
||||||
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
|
echo "alias_tags=${alias_tags[*]}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
# Build metadata
|
# Build metadata
|
||||||
@@ -70,9 +92,11 @@ jobs:
|
|||||||
id: meta
|
id: meta
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
${{ env.IMAGE_NAME }}
|
$IMAGE_NAME
|
||||||
labels: |
|
labels: |
|
||||||
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/base/main/README.md
|
org.opencontainers.image.title=$IMAGE_NAME
|
||||||
|
org.opencontainers.image.description=A base $IMAGE_NAME image with batteries included
|
||||||
|
io.artifacthub.package.readme-url=https://raw.githubusercontent.com/ublue-os/base/base/README.md
|
||||||
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4
|
io.artifacthub.package.logo-url=https://avatars.githubusercontent.com/u/120078124?s=200&v=4
|
||||||
|
|
||||||
# Build image using Buildah action
|
# Build image using Buildah action
|
||||||
@@ -85,9 +109,8 @@ jobs:
|
|||||||
image: ${{ env.IMAGE_NAME }}
|
image: ${{ env.IMAGE_NAME }}
|
||||||
tags: |
|
tags: |
|
||||||
${{ steps.generate-tags.outputs.alias_tags }}
|
${{ steps.generate-tags.outputs.alias_tags }}
|
||||||
${{ steps.generate-tags.outputs.date }}
|
|
||||||
${{ steps.generate-tags.outputs.sha_short }}
|
|
||||||
build-args: |
|
build-args: |
|
||||||
|
IMAGE_NAME=${{ matrix.image_name }}
|
||||||
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
|
FEDORA_MAJOR_VERSION=${{ matrix.major_version }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
oci: false
|
oci: false
|
||||||
@@ -135,12 +158,19 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
# Sign container
|
||||||
|
- uses: sigstore/cosign-installer@v3.0.1
|
||||||
|
if: github.event_name != 'pull_request'
|
||||||
|
|
||||||
- name: Sign container image
|
- name: Sign container image
|
||||||
run: |
|
run: |
|
||||||
cosign sign --key cosign.key ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS}
|
echo "${{ env.COSIGN_PRIVATE_KEY }}" > cosign.key
|
||||||
|
wc -c cosign.key
|
||||||
|
cosign sign -y --key cosign.key ${{ steps.registry_case.outputs.lowercase }}/${{ env.IMAGE_NAME }}@${TAGS}
|
||||||
env:
|
env:
|
||||||
TAGS: ${{ steps.push.outputs.digest }}
|
TAGS: ${{ steps.push.outputs.digest }}
|
||||||
COSIGN_EXPERIMENTAL: false
|
COSIGN_EXPERIMENTAL: false
|
||||||
|
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
|
||||||
|
|
||||||
- name: Echo outputs
|
- name: Echo outputs
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user