From 7938050c477974d5b09a17d06db20799f4229226 Mon Sep 17 00:00:00 2001 From: James Andariese Date: Thu, 28 Mar 2024 22:03:43 -0500 Subject: [PATCH] change to k-branches the history changing on every commit felt very yucky. --- .github/workflows/build.yaml | 32 +++++++++++++++++++++++++++++--- k/flux.yaml | 2 +- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index fea9260..d93393e 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -21,9 +21,35 @@ jobs: docker tag "`cat iid.txt`" "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG" docker push "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG" done - sed -i -e "s@image: $DOCKER_REGISTRY/$GITHUB_REPOSITORY:.*@image: $DOCKER_REGISTRY/$GITHUB_REPOSITORY:$STAG@" k/runner.yaml + + BRANCH="$GITHUB_REF_NAME" + KBRANCH="k-$GITHUB_REF_NAME" + git config user.name "$GITHUB_REPOSITORY (act)" git config user.email "gitea-actions@strudelline.net" - git add k/runner.yaml + + # ensure the branch exists so we can ensure it's deleted. no errors at all. + git checkout -B "$KBRANCH" + git checkout "$BRANCH" + git branch -D "$KBRANCH" + git checkout -b "$KBRANCH" + + # now fix up the images in k/runner.yaml + sed -i -e "s@image: $DOCKER_REGISTRY/$GITHUB_REPOSITORY:.*@image: $DOCKER_REGISTRY/$GITHUB_REPOSITORY:$STAG@" k/runner.yaml + sed -i -e "s@branch: .*@$KBRANCH@" k/flux.yaml + + git add k git commit -m "upgrade runner sts to $STAG" - git push + git push -f origin k-$GITHUB_REF_NAME + + # now let's fix the origin branch's flux.yaml if it's needed. + # this will only happen once so it's not such an awful UX. + git checkout "$BRANCH" + sed -i -e "s@branch: .*@$KBRANCH@" k/flux.yaml + + if git diff | grep -q .;then + echo fixing branch in flux.yaml of the origin branch + git add k/flux.yaml + git commit -m "fix flux.yaml in $BRANCH" + git push + fi diff --git a/k/flux.yaml b/k/flux.yaml index 80d1ce0..1065c94 100644 --- a/k/flux.yaml +++ b/k/flux.yaml @@ -8,7 +8,7 @@ spec: interval: 5m url: https://git.strudelline.net/cascade/docker-act_runner ref: - branch: main + branch: k-main --- apiVersion: kustomize.toolkit.fluxcd.io/v1 kind: Kustomization