Skip to content

Commit

Permalink
Use git HEAD instead of named branch
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrolamas committed Dec 12, 2024
1 parent 77de86e commit 3d6cb19
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Release

on:
push:
branches:
- master
schedule:
- cron: "0 * * * *"
workflow_dispatch:
Expand Down Expand Up @@ -29,8 +32,8 @@ jobs:
- name: Get Klipper and Moonraker metadata
id: repo
run: |
KLIPPER_SHA=$(git ls-remote $KLIPPER_REPOSITORY master | awk '{print $1}')
MOONRAKER_SHA=$(git ls-remote $MOONRAKER_REPOSITORY master | awk '{print $1}')
KLIPPER_SHA=$(git ls-remote $KLIPPER_REPOSITORY HEAD | awk '{print $1}')
MOONRAKER_SHA=$(git ls-remote $MOONRAKER_REPOSITORY HEAD | awk '{print $1}')
IMAGE_SHA=$(echo $KLIPPER_SHA-$MOONRAKER_SHA | sha1sum | awk '{print $1}')
echo "klipper_sha=${KLIPPER_SHA}" >> $GITHUB_OUTPUT
Expand All @@ -40,7 +43,7 @@ jobs:
- name: Check if new Docker image should be built
id: check
run: |
BUILD_IMAGE=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.forceBuild == 'true' }}
BUILD_IMAGE=${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.forceBuild == 'true') }}
if ! "$BUILD_IMAGE"; then
docker buildx imagetools inspect ghcr.io/${{ github.repository }}:sha-${{ steps.repo.outputs.image_sha }} > /dev/null || BUILD_IMAGE=true
Expand Down
3 changes: 2 additions & 1 deletion rootfs/usr/bin/restore-klipper-repo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ git --version &>/dev/null || (
git init
git remote add origin $KLIPPER_REPOSITORY
git fetch origin
git checkout -b master --track origin/master -f
DEFAULT_BRANCH=$(git remote show "${1:-origin}" | sed -n '/HEAD branch/s/.*: //p')
git checkout -b $DEFAULT_BRANCH --track origin/$DEFAULT_BRANCH -f
[ -n "$KLIPPER_SHA" ] && git reset --hard $KLIPPER_SHA || true
)
3 changes: 2 additions & 1 deletion rootfs/usr/bin/restore-moonraker-repo
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ git --version &>/dev/null || (
git init
git remote add origin $MOONRAKER_REPOSITORY
git fetch origin
git checkout -b master --track origin/master -f
DEFAULT_BRANCH=$(git remote show "${1:-origin}" | sed -n '/HEAD branch/s/.*: //p')
git checkout -b $DEFAULT_BRANCH --track origin/$DEFAULT_BRANCH -f
[ -n "$MOONRAKER_SHA" ] && git reset --hard $MOONRAKER_SHA || true
)

0 comments on commit 3d6cb19

Please sign in to comment.