Skip to content
34 changes: 34 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ jobs:
id: build-and-push-image
with:
image-flavor: "${{ matrix.image-flavor }}"
- name: Push latest tag
if: startsWith(github.ref, 'refs/tags/')
run: |
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
echo "Skipping latest push: tagged commit is not on main"
exit 0
fi
CURRENT="${{ github.ref_name }}"
LATEST="$(git tag --merged origin/main --sort=-version:refname | head -1)"
if [[ "${CURRENT}" != "${LATEST}" ]]; then
echo "Skipping latest push: ${CURRENT} is not the highest version tag on main (${LATEST} is)"
exit 0
fi
IMAGE="${{ steps.build-and-push-image.outputs.image-tag }}"
LATEST_IMAGE="quay.io/stackrox-io/apollo-ci:${{ matrix.image-flavor }}-latest"
docker tag "${IMAGE}" "${LATEST_IMAGE}"
docker push "${LATEST_IMAGE}"
- name: Save image info
run: |
mkdir -p image-info
Expand Down Expand Up @@ -67,6 +84,23 @@ jobs:
id: build-and-push-image
with:
image-flavor: "${{ matrix.image-flavor }}"
- name: Push latest tag
if: startsWith(github.ref, 'refs/tags/')
run: |
if ! git merge-base --is-ancestor "${{ github.sha }}" origin/main; then
echo "Skipping latest push: tagged commit is not on main"
exit 0
fi
CURRENT="${{ github.ref_name }}"
LATEST="$(git tag --merged origin/main --sort=-version:refname | head -1)"
if [[ "${CURRENT}" != "${LATEST}" ]]; then
echo "Skipping latest push: ${CURRENT} is not the highest version tag on main (${LATEST} is)"
exit 0
fi
IMAGE="${{ steps.build-and-push-image.outputs.image-tag }}"
LATEST_IMAGE="quay.io/stackrox-io/apollo-ci:${{ matrix.image-flavor }}-latest"
docker tag "${IMAGE}" "${LATEST_IMAGE}"
docker push "${LATEST_IMAGE}"
- name: Save image info
run: |
mkdir -p image-info
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/promote-stable.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Promote to stable

on:
workflow_dispatch:
inputs:
version:
description: "Version to promote (e.g. 0.5.7). Defaults to 'latest'."
required: false
default: "latest"

env:
QUAY_STACKROX_IO_RW_USERNAME: ${{ secrets.QUAY_STACKROX_IO_RW_USERNAME }}
QUAY_STACKROX_IO_RW_PASSWORD: ${{ secrets.QUAY_STACKROX_IO_RW_PASSWORD }}

jobs:
promote-stable:
runs-on: ubuntu-latest
steps:
- name: Log in to Quay
run: |
docker login -u "$QUAY_STACKROX_IO_RW_USERNAME" --password-stdin <<<"$QUAY_STACKROX_IO_RW_PASSWORD" quay.io
- name: Retag all flavors as stable
run: |
VERSION="${{ inputs.version }}"
VERSION="${VERSION:-latest}"
for flavor in scanner-build scanner-test stackrox-build stackrox-test stackrox-ui-test jenkins-plugin; do
SRC="quay.io/stackrox-io/apollo-ci:${flavor}-${VERSION}"
DST="quay.io/stackrox-io/apollo-ci:${flavor}-stable"
echo "Promoting ${SRC} → ${DST}"
docker buildx imagetools create --tag "${DST}" "${SRC}"
done
Loading