|
| 1 | +# This is the name of our workflow. |
| 2 | +# Github will show it on its Website UI |
1 | 3 | name: deploy
|
2 |
| - |
| 4 | +# This configures our workflow to be triggered |
| 5 | +# only when we push to the master branch |
3 | 6 | on:
|
4 | 7 | push:
|
5 | 8 | branches:
|
|
8 | 11 | types: [opened, synchronize, reopened, closed]
|
9 | 12 | branches:
|
10 | 13 | - master
|
| 14 | + |
11 | 15 | workflow_dispatch:
|
12 | 16 |
|
13 | 17 | env:
|
14 | 18 | RUBY_VERSION: "3.3.2"
|
15 | 19 | BUNDLER_VERSION: "2.5.11"
|
16 | 20 |
|
| 21 | +# Here is where we define our jobs. |
| 22 | +# Which means the tasks we want Github to execute |
17 | 23 | jobs:
|
18 | 24 | build:
|
19 |
| - name: Build site |
| 25 | + name: build |
| 26 | + # Here we specify in whith OS we want it to run |
20 | 27 | runs-on: ubuntu-latest
|
| 28 | + # Now we define which actions will take place. |
| 29 | + # One after another |
21 | 30 | steps:
|
22 |
| - - name: Checkout repository |
| 31 | + # This is the first action. It will make sure that we have |
| 32 | + # all the necessary files from our repo, including our custom actions |
| 33 | + # This action here is actually from a remote repo available from Githup itself |
| 34 | + - name: 🛎 Checkout master |
23 | 35 | uses: actions/checkout@v2
|
24 | 36 | with:
|
25 | 37 | fetch-depth: 1
|
26 |
| - - name: Install dependencies |
| 38 | + - name: ⚡️ Install dependencies |
27 | 39 | run: |
|
28 | 40 | sudo apt-get update
|
29 |
| - sudo apt-get install -y --no-install-recommends bats build-essential ca-certificates curl make shellcheck libgsl-dev libffi-dev |
| 41 | + sudo apt-get install -y --no-install-recommends bats build-essential ca-certificates curl make shellcheck libgsl-dev libffi-dev minify liblapacke-dev libopenblas-dev |
30 | 42 | sudo gem install bundler:${{ env.BUNDLER_VERSION }}
|
31 |
| - - name: Set up Ruby |
| 43 | + - name: Setup Ruby |
32 | 44 | uses: ruby/setup-ruby@v1
|
33 | 45 | with:
|
34 |
| - ruby-version: ${{ env.RUBY_VERSION }} |
35 |
| - bundler-cache: true |
36 |
| - - name: Cache node modules |
| 46 | + ruby-version: ${{ env.RUBY_VERSION }} # Not needed with a .ruby-version file |
| 47 | + bundler-cache: true # runs 'bundle install' and caches installed gems automatically |
| 48 | + - name: ⚡️ Cache node modules |
37 | 49 | uses: actions/cache@v3
|
| 50 | + env: |
| 51 | + cache-name: cache-node-modules |
38 | 52 | with:
|
| 53 | + # npm cache files are stored in `~/.npm` on Linux/macOS |
39 | 54 | path: ~/.npm
|
40 |
| - key: ${{ runner.os }}-build-${{ hashFiles('**/package-lock.json') }} |
41 |
| - - name: Install JS dependencies |
42 |
| - run: npm install |
43 |
| - - name: Check Jekyll configuration |
| 55 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 58 | + ${{ runner.os }}-build- |
| 59 | + ${{ runner.os }}- |
| 60 | + - name: ⚡️ Setting up dependencies |
| 61 | + continue-on-error: true |
| 62 | + run: | |
| 63 | + npm install |
| 64 | + - name: Checking Jekyll configuration |
44 | 65 | run: bundle exec jekyll doctor
|
45 |
| - - name: Build site |
46 |
| - run: bundle exec jekyll build --lsi --profile |
| 66 | + - name: 🔨 Build site |
| 67 | + run: | |
| 68 | + bundle exec jekyll build --lsi --profile |
47 | 69 | env:
|
48 | 70 | JEKYLL_ENV: production
|
49 |
| - - name: Cache jekyll site |
| 71 | + #- name: Optimize |
| 72 | + # run: | |
| 73 | + # minify -r -o _site/ --html-keep-document-tags --html-keep-end-tags --html-keep-default-attrvals --html-keep-whitespace --verbose _site |
| 74 | + - name: Cache Jekyll site |
50 | 75 | uses: actions/cache@v3
|
51 | 76 | with:
|
52 | 77 | path: "_site/"
|
53 | 78 | key: ${{ runner.os }}-${{ github.sha }}
|
54 |
| - |
| 79 | +# npm run build:js |
| 80 | +# - name: 🔨 Test calculations JS |
| 81 | +# run: | |
| 82 | +# npm run test |
55 | 83 | deploy:
|
| 84 | + if: github.event_name == 'push' |
| 85 | + name: deploy |
56 | 86 | needs: build
|
57 | 87 | runs-on: ubuntu-latest
|
58 | 88 | steps:
|
59 |
| - - name: Deploy to GitHub Pages |
| 89 | + - name: Use cache |
| 90 | + uses: actions/cache@v3 |
| 91 | + with: |
| 92 | + path: "_site/" |
| 93 | + key: ${{ runner.os }}-${{ github.sha }} |
| 94 | + - name: 🎉 Deploy to GitHub Pages 🎊 |
| 95 | + if: success() |
60 | 96 | uses: crazy-max/ghaction-github-pages@v2
|
61 | 97 | with:
|
62 | 98 | target_branch: gh-pages
|
63 | 99 | build_dir: _site
|
64 | 100 | env:
|
65 | 101 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
66 |
| - |
67 | 102 | test:
|
68 | 103 | needs: build
|
69 | 104 | runs-on: ubuntu-latest
|
70 | 105 | steps:
|
71 |
| - - name: Check HTML with HTMLProofer |
| 106 | + - name: Use cache |
| 107 | + uses: actions/cache@v3 |
| 108 | + with: |
| 109 | + path: "_site/" |
| 110 | + key: ${{ runner.os }}-${{ github.sha }} |
| 111 | + - name: ⚡️ Cache HTMLProofer |
| 112 | + id: cache-htmlproofer |
| 113 | + uses: actions/cache@v3 |
| 114 | + with: |
| 115 | + path: tmp/.htmlproofer |
| 116 | + key: ${{ runner.os }}-htmlproofer |
| 117 | + - name: 📉 Check HTML |
72 | 118 | uses: chabad360/htmlproofer@master
|
73 | 119 | with:
|
74 |
| - directory: ./_site |
75 |
| - arguments: "--only-4xx --ignore-status-codes '400,403,409,429'" |
76 |
| - |
| 120 | + directory: "./_site" |
| 121 | + # The directory to scan |
| 122 | + arguments: | |
| 123 | + --only-4xx |
| 124 | + --ignore-status-codes "400,403,409,429" |
| 125 | + --ignore-empty-alt |
| 126 | + --allow-hash-href |
| 127 | + --no-enforce-https |
| 128 | + --ignore-urls "/bjsm.bmj.com/, /mademistakes.com/, /www.t-nation.com/" |
77 | 129 | clean:
|
78 |
| - needs: build |
| 130 | + needs: [build,deploy,test] |
79 | 131 | runs-on: ubuntu-latest
|
80 | 132 | steps:
|
81 |
| - - name: Clean build artifacts |
| 133 | + - name: Use cache |
| 134 | + uses: actions/cache@v3 |
| 135 | + with: |
| 136 | + path: "_site/" |
| 137 | + key: ${{ runner.os }}-${{ github.sha }} |
| 138 | + - name: ☁️ Cleaning up |
82 | 139 | run: bundle exec jekyll clean
|
0 commit comments