fix: Avoid workflow failure on unchanged docs #34
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: 'CI/CD' | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches: | |
- 'master' | |
concurrency: | |
group: test-${{ github.ref }} | |
cancel-in-progress: true | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
# Build and test | |
Build-and-Test: | |
runs-on: ubuntu-latest | |
container: ghcr.io/galacticusorg/buildenv:latest | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Generate configure | |
run: | | |
cd $GITHUB_WORKSPACE | |
apt update | |
apt install -y bison flex | |
git config --global --add safe.directory $GITHUB_WORKSPACE | |
set -o pipefail | |
mkdir -p config | |
mkdir -p m4 | |
touch config/config.rpath | |
autoreconf --install --force -I/usr/local/share/aclocal | |
CFLAGS="-I/usr/include/x86_64-linux-gnu" ./configure | |
make dist | |
cd doc | |
make libmatheval.html | |
- name: Upload artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: release-archive | |
path: 'libmatheval-1.1.12.tar.gz' | |
- name: Upload docs artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: docs | |
path: 'doc/libmatheval.html' | |
- name: Build and test | |
run: | | |
make -j2 2>&1 | tee build.log | |
grep -v -q Error: build.log | |
grep -v -q Warning: build.log | |
make -j2 check 2>&1 | tee build.log | |
grep -v -q Error: build.log | |
grep -v -q Warning: build.log | |
set +o pipefail | |
Update-Release-Tag: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
needs: Build-and-Test | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: release-archive | |
- name: Upload to release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gh release upload latest libmatheval-1.1.12.tar.gz --clobber | |
- name: Update tag | |
run: | | |
git tag -f latest | |
git push origin -f latest | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
Update-Online-Docs: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/master' | |
needs: Build-and-Test | |
steps: | |
- name: Check out repository code | |
uses: actions/checkout@v3 | |
with: | |
ref: gh-pages | |
- name: Remove old docs | |
run: | | |
mkdir -p doc | |
rm -rf doc | |
mkdir -p doc | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: docs | |
path: doc | |
- name: Update online docs | |
run: | | |
git config --global --add safe.directory $GITHUB_WORKSPACE | |
git config --local user.email "[email protected]" | |
git config --local user.name "github-action-validate" | |
git add doc | |
if [ git diff --cached --quiet ]; then | |
git commit -m "Update documentation" | |
git push --set-upstream origin gh-pages | |
fi | |
if: github.event_name != 'pull_request' |