diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99e1899..e5f0a96 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,11 +17,28 @@ concurrency: env: REGISTRY: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s IMAGE: riscv-runner - RELEASE_ENVIRONMENT: ${{ (github.ref == 'refs/heads/main' && 'prod') || (github.ref == 'refs/heads/staging' && 'staging') || '' }} jobs: - build-and-deploy: + resolve: runs-on: ubuntu-latest + outputs: + environment: ${{ steps.env.outputs.result }} + steps: + - id: env + run: | + if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then + echo "result=main" >> $GITHUB_OUTPUT + elif [[ "${{ github.ref }}" == "refs/heads/staging" ]]; then + echo "result=staging" >> $GITHUB_OUTPUT + fi + + deploy: + if: github.repository_owner == 'riseproject-dev' && needs.resolve.outputs.environment != '' + needs: [resolve] + runs-on: ubuntu-latest + environment: ${{ needs.resolve.outputs.environment }} + env: + TAG: ${{ (needs.resolve.outputs.environment == 'main' && 'latest') || 'staging' }} steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 diff --git a/Makefile b/Makefile index fcb24b6..86a5b65 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,9 @@ REGISTRY ?= rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s IMAGE ?= riscv-runner +TAG ?= staging GOARCH ?= riscv64 + .PHONY: build build: build-device-plugin build-node-labeller @@ -18,31 +20,32 @@ container-build: container-build-device-plugin container-build-node-labeller .PHONY: container-build-device-plugin container-build-device-plugin: - docker build --platform linux/riscv64 -f Dockerfile -t $(REGISTRY)/$(IMAGE):device-plugin-latest . + docker build --platform linux/riscv64 -f Dockerfile -t $(REGISTRY)/$(IMAGE):device-plugin-$(TAG) . .PHONY: container-build-node-labeller container-build-node-labeller: - docker build --platform linux/riscv64 -f labeller.Dockerfile -t $(REGISTRY)/$(IMAGE):node-labeller-latest . + docker build --platform linux/riscv64 -f labeller.Dockerfile -t $(REGISTRY)/$(IMAGE):node-labeller-$(TAG) . .PHONY: container-push container-push: container-push-device-plugin container-push-node-labeller .PHONY: container-push-device-plugin container-push-device-plugin: - docker build --platform linux/riscv64 -f Dockerfile -t $(REGISTRY)/$(IMAGE):device-plugin-latest . - docker push $(REGISTRY)/$(IMAGE):device-plugin-latest + docker build --platform linux/riscv64 -f Dockerfile -t $(REGISTRY)/$(IMAGE):device-plugin-$(TAG) . + docker push $(REGISTRY)/$(IMAGE):device-plugin-$(TAG) .PHONY: container-push-node-labeller container-push-node-labeller: - docker build --platform linux/riscv64 -f labeller.Dockerfile -t $(REGISTRY)/$(IMAGE):node-labeller-latest . - docker push $(REGISTRY)/$(IMAGE):node-labeller-latest + docker build --platform linux/riscv64 -f labeller.Dockerfile -t $(REGISTRY)/$(IMAGE):node-labeller-$(TAG) . + docker push $(REGISTRY)/$(IMAGE):node-labeller-$(TAG) .PHONY: kubectl-apply kubectl-apply: kubectl-apply-device-plugin kubectl-apply-node-labeller .PHONY: kubectl-apply-device-plugin kubectl-apply-device-plugin: - kubectl apply -f k8s-ds-device-plugin.yaml + test -n $(TAG) || echo "TAG must be defined" + cat k8s-ds-device-plugin.yaml | env TAG="$(TAG)" envsubst | kubectl apply -f - kubectl rollout restart daemonset/rise-riscv-runner-device-plugin -n kube-system .PHONY: kubectl-apply-and-wait-device-plugin @@ -51,7 +54,8 @@ kubectl-apply-and-wait-device-plugin: kubectl-apply-device-plugin .PHONY: kubectl-apply-node-labeller kubectl-apply-node-labeller: - kubectl apply -f k8s-ds-node-labeller.yaml + test -n $(TAG) || echo "TAG must be defined" + cat k8s-ds-node-labeller.yaml | env TAG="$(TAG)" envsubst | kubectl apply -f - kubectl rollout restart daemonset/rise-riscv-runner-node-labeller -n kube-system .PHONY: clean diff --git a/k8s-ds-device-plugin.yaml b/k8s-ds-device-plugin.yaml index 9fe3dcb..c03b20e 100644 --- a/k8s-ds-device-plugin.yaml +++ b/k8s-ds-device-plugin.yaml @@ -25,25 +25,17 @@ spec: kubernetes.io/arch: riscv64 priorityClassName: system-node-critical initContainers: - - name: ubuntu-2404-latest-image-cache - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:ubuntu-24.04-latest + - name: ubuntu-2404-image-cache + image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:ubuntu-24.04-${TAG} imagePullPolicy: Always command: ["true"] - - name: ubuntu-2404-staging-image-cache - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:ubuntu-24.04-staging - imagePullPolicy: Always - command: ["true"] - - name: dind-latest-image-cache - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:dind-latest - imagePullPolicy: Always - command: ["true"] - - name: dind-staging-image-cache - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:dind-staging + - name: dind-image-cache + image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:dind-${TAG} imagePullPolicy: Always command: ["true"] containers: - name: device-plugin - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:device-plugin-latest + image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:device-plugin-${TAG} imagePullPolicy: Always volumeMounts: - name: device-plugins diff --git a/k8s-ds-node-labeller.yaml b/k8s-ds-node-labeller.yaml index 8b5923b..0138b8a 100644 --- a/k8s-ds-node-labeller.yaml +++ b/k8s-ds-node-labeller.yaml @@ -50,7 +50,7 @@ spec: kubernetes.io/arch: riscv64 containers: - name: node-labeller - image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:node-labeller-latest + image: rg.fr-par.scw.cloud/funcscwriseriscvrunnerappqdvknz9s/riscv-runner:node-labeller-${TAG} imagePullPolicy: Always env: - name: NODE_NAME diff --git a/pkg/soc/detect.go b/pkg/soc/detect.go index 17f1fd6..87cf5fe 100644 --- a/pkg/soc/detect.go +++ b/pkg/soc/detect.go @@ -11,7 +11,7 @@ import ( var boardMap = map[string]string{ "scaleway,em-rv1-c4m16s128-a": "scw-em-rv1", "sophgo,mango": "cloudv10x-pioneer", - "spacemit,k1-x": "cloudv10x-jupyter", + "spacemit,k1-x": "cloudv10x-jupiter", } // DetectBoard reads the device tree compatible property and maps it to a board name.