Skip to content

Commit 8b703ef

Browse files
committed
Actions: Pass commit info from "build" to "deploy"
1 parent c210cae commit 8b703ef

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

.github/workflows/build.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ on:
77
jobs:
88
build:
99
runs-on: ubuntu-latest
10+
outputs:
11+
commit-info: ${{ steps.commit-info.outputs.COMMIT_INFO }}
1012
steps:
1113
- uses: actions/checkout@v4
1214
with:
@@ -64,6 +66,11 @@ jobs:
6466
with:
6567
path: site
6668

69+
- name: Generate commit info
70+
id: commit-info
71+
run: |
72+
git log -1 --pretty="COMMIT_INFO=%an: [%h] %s" >> "$GITHUB_OUTPUT"
73+
6774
deploy:
6875
needs: build
6976
if: github.ref == 'refs/heads/master'
@@ -88,15 +95,14 @@ jobs:
8895

8996
- name: Push site to gh-pages branch
9097
run: |
91-
CINFO="$(git log -1 --pretty="%an: [%h] %s")"
9298
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \
93-
"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" test
99+
"https://${{ github.actor }}:${{ github.token }}@github.com/${{ github.repository }}.git" test
94100
mv test/.git site/.git && rmdir test/
95101
pushd site/ &>/dev/null
96102
git add -A
97103
git -c user.name=GitHub -c [email protected] commit \
98104
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \
99-
-m "$CINFO" \
105+
-m "${{ needs.build.outputs.commit-info }}" \
100106
--allow-empty
101107
git push
102108
popd &>/dev/null

0 commit comments

Comments
 (0)