Updated workflow #3
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: Apptainer Build | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- README.md.esh | |
- .github/workflows/scripts/esh | |
- .github/workflows/build-documentation.yml | |
- runscript.help.esh | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
name: Build documentation | |
permissions: write-all | |
steps: | |
- name: Check out code for the container build | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Build documentation and installer in one step | |
shell: bash | |
run: | | |
set -eux -o pipefail | |
# Run esh to fill in the variables: | |
"${GITHUB_WORKSPACE}/.github/workflows/scripts/esh" "${GITHUB_WORKSPACE}/runscript.help.esh" > "${GITHUB_WORKSPACE}/runscript.help" | |
"${GITHUB_WORKSPACE}/.github/workflows/scripts/esh" "${GITHUB_WORKSPACE}/README.md.esh" > "${GITHUB_WORKSPACE}/README.md" | |
# Stage files: | |
git add README.md runscript.help | |
# Build additions to commit message: | |
add_to_commit_msg="" | |
if git diff --staged --name-only "README.md" | grep -Fq "README.md"; then | |
add_to_commit_msg="GITHUB_ACTION=\"${GITHUB_ACTION:-}\": Templated \"README.md\" for GITHUB_REPOSITORY=\"${GITHUB_REPOSITORY}\"" | |
fi | |
if git diff --staged --name-only "runscript.help" | grep -Fq "runscript.help"; then | |
add_to_commit_msg="${add_to_commit_message:+${add_to_commit_message:-}\n}GITHUB_ACTION=\"${GITHUB_ACTION:-}\": Templated \"runscript.help\" for GITHUB_REPOSITORY=\"${GITHUB_REPOSITORY}\"" | |
fi | |
# Don't append to commit message: | |
if [[ -n "${add_to_commit_msg:-}" ]]; then | |
if [[ "${GITHUB_REF_TYPE:-}" == "tag" ]] && [[ "${GITHUB_REF}" =~ ^.*@.*$ ]]; then | |
echo "Not appending commit messages because this is a tagged release" >&2 | |
echo -e "Would have added:\n\"${add_to_commit_msg:-}\"" | |
else | |
# Get the last commit message, if any: | |
last_commit_msg="$(git log -1 --pretty=format:%B || true)" | |
commit_msg="${last_commit_msg:+${last_commit_msg}\n}${add_to_commit_msg}" | |
# Set up git config for push: | |
git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com" | |
git config --local user.name ${{ github.event.sender.login }} | |
git commit -am "${commit_msg}" && git push --force | |
fi | |
fi | |