99jobs :
1010 check :
1111 name : " Content check"
12- runs-on : ubuntu-20.04
12+ runs-on : ubuntu-latest
1313 steps :
1414 - name : " Checkout repo"
1515 uses : actions/checkout@v4
4949 fi
5050 build :
5151 name : " Build preview"
52- runs-on : ubuntu-20.04
52+ runs-on : ubuntu-latest
5353 outputs :
5454 PR_ID : ${{steps.details.outputs.PR_ID}}
5555 PREVIEW_PATH : ${{steps.details.outputs.PREVIEW_PATH}}
@@ -119,15 +119,21 @@ jobs:
119119 - name : " Run htmlproofer"
120120 run : docker run --rm --mount type=bind,source=$(pwd),target=/srv/site --entrypoint "/bin/bash" ovirt-site -c "bundle exec ruby htmlproofer_test.rb"
121121 publish :
122+ permissions :
123+ contents : write
122124 name : " Publish preview"
123- runs-on : ubuntu-20.04
125+ runs-on : ubuntu-latest
124126 needs :
125127 - check
126128 - build
127129 concurrency :
128130 group : ovirt-site-preview-build
129131 cancel-in-progress : false
130132 steps :
133+ - name : set git defaults
134+ run : |
135+ git config --global user.name 'github-actions[bot]'
136+ git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
131137 - name : " Checkout repo"
132138 uses : actions/checkout@v4
133139 with :
@@ -144,22 +150,19 @@ jobs:
144150 path : " ${{needs.build.outputs.PREVIEW_PATH}}"
145151 - name : " Commit changes"
146152 run : |
147- set -euo pipefail
148- git config --global user.name 'github-actions[bot]'
149- git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
150- git add .
151- if ! git diff-index --quiet HEAD --; then
152- git commit -m "Adding or updating preview build for PR ${{needs.build.outputs.PR_ID}}"
153- git push --set-upstream origin gh-pages
154- else
155- echo -e "No changes found."
153+ commit=$(git log --format="%H" -n 1)
154+ description=$(git describe --always)
155+ if git status --porcelain 2>/dev/null| grep -E "^??|^M"
156+ then
157+ git add .
158+ git commit -m "gh-pages ${description} ${commit}"
159+ git push
156160 fi
157161 env :
158162 GITHUB_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
159163 - name : " Send comment to PR"
160164 continue-on-error : true
161165 run : |
162- set -euo pipefail
163166 echo "Your preview build is ready! ✨ Check the following link in 1-2 minutes: ${{needs.build.outputs.PREVIEW_LINK}} ." >/tmp/comment
164167 gh pr comment ${{needs.build.outputs.PR_ID}} -F /tmp/comment
165168 env :
0 commit comments