Skip to content

Commit 50ba949

Browse files
committed
Repair getting the right commit for build-metadata
1 parent 8dad9d4 commit 50ba949

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/build-preview-pages.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,16 @@ jobs:
1616
runs-on: ubuntu-latest
1717
env:
1818
ACTING_SHA: ${{ github.sha }}
19-
POSITION_FROM_TOP: 1
19+
POSITION_FROM_TOP: 2
2020
OUTPUT_NAME: 'machinekit-site-${{ github.sha }}'
2121
ACTING_REPOSITORY: ${{ github.repository }}
2222
steps:
23+
# Hack uptil conditional setting of environment variable is posible
24+
# (or this is reworked into an action)
25+
- name: Test for pull request or push
26+
if: github.event_name == 'push'
27+
run: echo ::set-env name=POSITION_FROM_TOP::1
28+
2329
# Locally clone the repository which we want to build with depth of 5 commits
2430
- name: Checkout the pull request for Machinekit-docs
2531
uses: actions/checkout@v2
@@ -53,8 +59,8 @@ jobs:
5359
echo "###########################################################"
5460
echo "# Commit which will be used for mining of the credentials #"
5561
echo "###########################################################"
56-
git log -n 1 ${{ env.ACTING_SHA }}~$((${{ env.POSITION_FROM_TOP }}-1))
57-
jq -n --arg authoremail "$(git log --format='%ae' -n 1 ${{ env.ACTING_SHA }}~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg authorname "$(git log --format='%an' -n 1 ${{ env.ACTING_SHA }}~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg commitmsg "$(git log --format='%B' -n 1 ${{ env.ACTING_SHA }}~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg sha "${{ env.ACTING_SHA }}" '{"author":"\($authorname)","email":"\($authoremail)","message":"\($commitmsg)","sha":"\($sha)"}' > ${{ env.FILENAME }}
62+
git log -n 1 HEAD~$((${{ env.POSITION_FROM_TOP }}-1))
63+
jq -n --arg authoremail "$(git log --format='%ae' -n 1 HEAD~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg authorname "$(git log --format='%an' -n 1 HEAD~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg commitmsg "$(git log --format='%B' -n 1 HEAD~$((${{ env.POSITION_FROM_TOP }}-1)))" --arg sha "${{ env.ACTING_SHA }}" '{"author":"\($authorname)","email":"\($authoremail)","message":"\($commitmsg)","sha":"\($sha)"}' > ${{ env.FILENAME }}
5864
echo "###########################################################"
5965
echo "# JSON file with metadata information of pertinent commit #"
6066
echo "###########################################################"

0 commit comments

Comments
 (0)