fix #70
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: build | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
LSI: "true" | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.0" | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
# - name: Cache Ruby gems | |
# uses: actions/cache@v4 | |
# env: | |
# CACHE_ID: 1 | |
# with: | |
# path: | | |
# Gemfile.lock | |
# vendor/bundle | |
# key: ${{ runner.os }}-bundler-${{ env.CACHE_ID }}-${{ hashFiles('Gemfile') }} | |
# restore-keys: | | |
# ${{ runner.os }}-bundler-${{ env.CACHE_ID }}- | |
# - name: Cache Node modules | |
# uses: actions/cache@v4 | |
# env: | |
# CACHE_ID: 1 | |
# with: | |
# path: ~/.npm | |
# key: ${{ runner.os }}-npm-${{ env.CACHE_ID }}-${{ hashFiles('**/package-lock.json') }} | |
# restore-keys: | | |
# ${{ runner.os }}-npm-${{ env.CACHE_ID }}- | |
- name: Install dependencies | |
run: | | |
sudo apt-get install -y libgsl-dev | |
bundle config set --local path vendor/bundle | |
bundle config set without 'development' | |
bundle install --jobs=4 --retry=3 | |
bundle clean | |
npm install --include=dev | |
- name: "Linting: autocorrect" | |
continue-on-error: true | |
run: | | |
curl -fsSL https://raw.githubusercontent.com/huacnlee/autocorrect/main/install | sh | |
autocorrect --fix ./* | |
- name: Prettier fix | |
continue-on-error: true | |
run: npm run fix | |
- name: Determine if a PR should be submitted | |
if: github.ref == 'refs/heads/main' | |
id: file_changes | |
run: | | |
git add -A | |
if git diff-index --quiet --cached HEAD --; then | |
echo "Changes detected. Exiting the workflow." | |
exit 1 | |
else | |
echo "No changes detected. Continuing the workflow." | |
fi | |
- name: Prepare build | |
if: github.ref == 'refs/heads/main' | |
run: | | |
git clone --depth=1 --branch=gh-pages --single-branch --no-checkout \ | |
"https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" \ | |
_site | |
- name: Run Jekyll Doctor | |
run: | | |
bundle exec jekyll doctor --trace --profile | |
env: | |
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build site | |
run: | | |
bundle exec jekyll build --trace --profile | |
: > _site/.nojekyll | |
env: | |
JEKYLL_ENV: production | |
JEKYLL_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Deploy to GitHub Pages | |
if: github.ref == 'refs/heads/main' | |
run: | | |
CINFO="$(git log -1 --pretty="%an: [%h] %s")" | |
pushd _site/ &>/dev/null | |
git add -A | |
git -c user.name=GitHub -c [email protected] commit \ | |
-m "Auto deploy from GitHub Actions build ${GITHUB_RUN_NUMBER}" \ | |
-m "$CINFO" | |
git push | |
popd &>/dev/null |