Skip to content

Commit

Permalink
Publish the manifest in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
nwneisen committed Sep 20, 2024
1 parent 5717a4c commit b0b47b2
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/Merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ jobs:
needs: [vet, test, e2e, build]
secrets: inherit
uses: ./.github/workflows/push-to-ghcr.yml
push-manifest:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # if all `needs` jobs are successful
needs: [vet, test, e2e, build]
secrets: inherit
uses: ./.github/workflows/push-manifest.yml
cleanup:
needs: [vet, test, e2e, build, push-to-ghcr]
secrets: inherit
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/Release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ jobs:
needs: [vet, test, build, e2e]
secrets: inherit
uses: ./.github/workflows/push-to-ghcr.yml
push-manifest:
if: ${{ always() && contains(join(needs.*.result, ','), 'success') }} # if all `needs` jobs are successful
needs: [vet, test, build, e2e]
secrets: inherit
uses: ./.github/workflows/push-manifest.yml
cleanup:
if: ${{ always() }} # always run this job
needs: [push-to-ghcr]
Expand Down
71 changes: 71 additions & 0 deletions .github/workflows/push-manifest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Push manifest

on:
workflow_call:

jobs:
push-semver:
if: ${{ github.event_name == 'release' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Push latest image to ${{ env.REGISTRY }}
working-directory: .
run: |
SEMVER=${GITHUB_REF#refs/*/}
echo ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
docker tag ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:latest ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
docker push ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:$SEMVER
- name: Publish the manifest to the public blueprint repository
uses: softprops/action-gh-release@v1
with:
name: $SEMVER
tag_name: $SEMVER
repository: nwneisen/blueprint
token: ${{ secrets.PAT_CI_BOUNDLESS }}
files: |
**/deploy/static/blueprint-operator.yaml
- name: Publish the manifest to the private operator repository
uses: softprops/action-gh-release@v1
with:
name: $SEMVER
tag_name: $SEMVER
repository: nwneisen/blueprint-operator
token: ${{ secrets.PAT_CI_BOUNDLESS }}
files: |
**/deploy/static/blueprint-operator.yaml
push-dev:
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Load environment
uses: c-py/action-dotenv-to-setenv@v4
with:
env-file: .github/development.env

- name: Publish the manifest to the private operator repository
uses: softprops/action-gh-release@v1
with:
name: dev
tag_name: dev
make_latest: false
body: "This is the dev build that always represents the latest commit on the main branch. These binaries change frequiently and are not meant for production use."
token: ${{ secrets.PAT_CI_BOUNDLESS }}
repository: nwneisen/blueprint-operator
files: |
**/deploy/static/blueprint-operator.yaml
2 changes: 1 addition & 1 deletion .github/workflows/push-to-ghcr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
working-directory: .
run: docker load --input /tmp/${{ env.IMAGE }}.tar

- name: Push SHA image to ${{ env.REGISTRY }}
- name: Push Dev image to ${{ env.REGISTRY }}
working-directory: .
run: |
docker tag ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:latest ${{ env.REGISTRY }}/${{ env.ORG }}/${{ env.IMAGE }}:dev
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/blueprint_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

// BlueprintSpec defines the desired state of Blueprint
type BlueprintSpec struct {
// Version is the version of the blueprint operator
Version string `json:"version,omitempty"`
// Components contains all the components that should be installed
Components Component `json:"components,omitempty"`
// Resources contains all object resources that should be installed
Expand Down
6 changes: 5 additions & 1 deletion api/v1alpha1/blueprint_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ package v1alpha1

import (
"fmt"
"strings"

"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
"strings"
)

const (
Expand Down Expand Up @@ -58,6 +59,9 @@ func (r *Blueprint) ValidateDelete() (admission.Warnings, error) {
}

func validate(spec BlueprintSpec) (admission.Warnings, error) {
if spec.Version == "" {
spec.Version = "latest"
}
if len(spec.Components.Addons) > 0 {
for _, val := range spec.Components.Addons {
if strings.EqualFold(kindChart, val.Kind) {
Expand Down
1 change: 0 additions & 1 deletion deploy/static/boundless-operator.yaml

This file was deleted.

0 comments on commit b0b47b2

Please sign in to comment.