Deploy Skiperator Sandbox #46
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: Deploy Skiperator Sandbox | |
on: | |
workflow_dispatch: | |
inputs: | |
image_digest: | |
description: "Image Digest of Skiperator version to deploy (sha:abc123.....)" | |
required: true | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
RBAC_FILE_PATH: config/rbac/role.yaml | |
CRD_APP_FILE_PATH: config/crd/skiperator.kartverket.no_applications.yaml | |
CRD_JOB_FILE_PATH: config/crd/skiperator.kartverket.no_skipjobs.yaml | |
ARTIFACT_NAME: skiperator-artifact-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }} | |
jobs: | |
generate: | |
name: CRD and ClusterRole | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Golang environment | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21.4' | |
- name: Generate CRD and ClusterRole | |
run: make generate | |
- name: Upload CRD and ClusterRole | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: | | |
${{ env.RBAC_FILE_PATH }} | |
${{ env.CRD_APP_FILE_PATH }} | |
${{ env.CRD_JOB_FILE_PATH }} | |
deploy-argo: | |
needs: [generate] | |
runs-on: ubuntu-latest | |
env: | |
BASE_DIR: ./sandbox/skiperator-system | |
TMP_FILE: tmp_kustomization.yaml | |
steps: | |
- name: Checkout apps repo | |
uses: actions/checkout@v4 | |
with: | |
repository: kartverket/skip-apps | |
token: ${{ secrets.SKIPERATOR_DEPLOY_SECRET }} | |
- name: Download CRD and RBAC | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ env.ARTIFACT_NAME }} | |
path: config/ | |
- name: Patch Image Digest | |
run: | | |
kubectl patch --type=merge --local \ | |
-f $BASE_DIR/kustomization.yaml \ | |
-p '{"images":[{"name":"${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}","digest":"${{ github.event.inputs.image_digest }}"}]}' \ | |
-o yaml > $BASE_DIR/$TMP_FILE | |
rm $BASE_DIR/kustomization.yaml | |
mv $BASE_DIR/$TMP_FILE $BASE_DIR/kustomization.yaml | |
- name: Update CRD and Role | |
run: | | |
cp -f -v $CRD_APP_FILE_PATH $BASE_DIR/patches/crd.yaml | |
cp -f -v $CRD_JOB_FILE_PATH $BASE_DIR/patches/skipjob-crd.yaml | |
cp -f -v $RBAC_FILE_PATH $BASE_DIR/patches/clusterrole.yaml | |
rm -rf config/ | |
- name: Commit Changes to Repo | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git commit -am "deploy skiperator branch: ${{github.ref_name}}" | |
git push |