Don't specify the password on the command line #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Convert Markdown to HTML | |
on: pull_request | |
jobs: | |
md2html: # make sure build/ci work properly | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- run: npm ci | |
- run: npm run grunt | |
- name: check if commit & push is needed | |
id: check | |
run: | | |
git add -A \*.html && | |
git diff-index --cached --exit-code HEAD -- || | |
echo "need-to-commit=yes" >>$GITHUB_OUTPUT | |
- name: commit | |
if: steps.check.outputs.need-to-commit == 'yes' | |
run: | | |
git config user.name "${{github.actor}}" && | |
git config user.email "${{github.actor}}@users.noreply.github.com" && | |
git commit -m 'Convert Markdown to HTML' -- \*.html && | |
git update-index --refresh && | |
git diff-files --exit-code && | |
git diff-index --cached --exit-code HEAD -- | |
- name: commit | |
if: steps.check.outputs.need-to-commit == 'yes' && github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name | |
run: git push | |
- name: publish temporary branch and add instructions how to fetch | |
if: steps.check.outputs.need-to-commit == 'yes' && github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name | |
run: | | |
auth="$(printf 'PAT:%s' '${{ secrets.GITHUB_TOKEN }}' | base64 -w 0)" && | |
echo "::add-mask::$auth" && | |
git -c http.extraHeader="Authorization: Basic $auth" push "${{ github.event.pull_request.base.repo.full_name }}" HEAD:refs/tmp/pr-${{ github.event.number }} && | |
echo '::error::HTML pages are out of date. Please call `git pull --ff-only ${{ github.event.pull_request.base.repo.full_name }}" refs/tmp/pr-${{ github.event.number }}` and push to the PR branch' >&2 | |
exit 1 |