docker-act_runner/.github/workflows/build.yaml
James Andariese 7938050c47
All checks were successful
Github Actions Demo / Explore-Gitea-Actions (push) Successful in 7s
change to k-branches
the history changing on every commit felt very yucky.
2024-03-28 22:45:32 -05:00

56 lines
2.0 KiB
YAML

name: Github Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions (on Gitea) 🚀
on:
push:
paths-ignore:
- k/**
jobs:
Explore-Gitea-Actions:
runs-on: metal-docker
steps:
- name: Check out repository code
uses: actions/checkout@v3
- run: |
ls -la
docker build --progress plain --iidfile iid.txt .
stringprefix() { [ ${#1} -le $2 ] && echo $1 && return 0 || stringprefix "${1%?}" $2 ; }
STAG="$GITHUB_REF_NAME-$(date +%Y-%m-%d-%H.%M.%S)"
SHORTSHA="$(stringprefix "$GITHUB_SHA" 8)"
for TAG in "$SHORTSHA" "$GITHUB_REF_NAME" "$STAG";do
docker tag "`cat iid.txt`" "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
docker push "$DOCKER_REGISTRY/$GITHUB_REPOSITORY:$TAG"
done
BRANCH="$GITHUB_REF_NAME"
KBRANCH="k-$GITHUB_REF_NAME"
git config user.name "$GITHUB_REPOSITORY (act)"
git config user.email "gitea-actions@strudelline.net"
# 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 -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