Generate website once per workflow

This commit is contained in:
Jonah Aragon 2021-05-02 14:43:11 -05:00
parent bbc09b5681
commit 52c8192f7a
No known key found for this signature in database
GPG Key ID: 6A957C9A9A9429F7
3 changed files with 86 additions and 202 deletions

View File

@ -3,8 +3,6 @@ description: 'Builds Jekyll Site'
runs: runs:
using: "composite" using: "composite"
steps: steps:
- shell: bash
run: npm install
- shell: bash - shell: bash
run: | run: |
sed -i "s/^ date:.*$/ date: $(TZ=UTC date "+%Y-%m-%d")/" _config.yml sed -i "s/^ date:.*$/ date: $(TZ=UTC date "+%Y-%m-%d")/" _config.yml

View File

@ -11,10 +11,9 @@ env:
FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }} FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }}
jobs: jobs:
deploy: build:
name: Rsync Deploy name: Jekyll Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
environment: production
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
@ -31,12 +30,33 @@ jobs:
.jekyll-cache .jekyll-cache
.sass-cache .sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }} key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
- name: Install dependencies
run: npm install
- name: Build website - name: Build website
uses: ./.github/actions/build uses: ./.github/actions/build
- run: tar cvf site.tar _site
- name: Upload generated Jekyll site
uses: actions/upload-artifact@v2
with:
name: generated-site
path: site.tar
deploy:
name: Rsync Deploy
runs-on: ubuntu-latest
environment: production
needs: build
steps:
- name: Download generated Jekyll site
uses: actions/download-artifact@v2
with:
name: generated-site
- run: tar xvf site.tar
- name: Copy built site to production - name: Copy built site to production
run: | run: |
mkdir -p ~/.ssh mkdir -p ~/.ssh
echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
chmod 700 ~/.ssh/id_rsa chmod 700 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
rsync -azP --delete ${{ github.workspace }}/_site/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:privacyguides.org-deploy rsync -azP --delete _site/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:privacyguides.org-deploy

View File

@ -18,9 +18,6 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -32,24 +29,23 @@ jobs:
with: with:
node-version: '14' node-version: '14'
- run: npm install - run: npm install
- run: npm run assets:install - run: tar cvf node_modules.tar node_modules
- name: Upload node_modules for Jekyll build
uses: actions/upload-artifact@v2
with:
name: node_modules
path: node_modules.tar
build: build:
name: "Jekyll Build" name: "Jekyll Build"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: deps
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
bundler-cache: true bundler-cache: true
- name: Cache node modules
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2 - uses: actions/setup-node@v2
with: with:
node-version: '14' node-version: '14'
@ -62,40 +58,36 @@ jobs:
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }} key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: | restore-keys: |
${{ runner.os }}-jekyll- ${{ runner.os }}-jekyll-
- name: Build website - name: Set Date and Time
uses: ./.github/actions/build run: |
sed -i "s/^ date:.*$/ date: $(TZ=UTC date "+%Y-%m-%d")/" _config.yml
sed -i "s/^ time:.*$/ time: $(TZ=UTC date "+%H:%M:%S %Z")/" _config.yml
- name: Download node_modules
uses: actions/download-artifact@v2
with:
name: node_modules
- run: tar xvf node_modules.tar
- name: Generate Website
run: npm run build
- run: tar cvf site.tar _site
- name: Upload generated Jekyll site
uses: actions/upload-artifact@v2
with:
name: generated-site
path: site.tar
link: link:
name: "Broken Hyperlinks (Internal)" name: "Broken Hyperlinks (Internal)"
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [deps, build] needs: build
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Copy built site to production - name: Copy built site to production
run: | run: |
mv ${{ github.workspace }}/_site /tmp/ mv ${{ github.workspace }}/_site /tmp/
@ -116,30 +108,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Cache HTMLProofer - name: Cache HTMLProofer
id: cache-htmlproofer id: cache-htmlproofer
uses: actions/cache@v2 uses: actions/cache@v2
@ -149,7 +122,7 @@ jobs:
restore-keys: | restore-keys: |
${{ runner.os }}-htmlproofer- ${{ runner.os }}-htmlproofer-
${{ runner.os }}-htmlproofer ${{ runner.os }}-htmlproofer
- name: Check All External Links (Informational) - name: Check All External Links (Informational, Soft-Fail)
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
directory: ${{ github.workspace }}/_site directory: ${{ github.workspace }}/_site
@ -168,30 +141,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check Images - name: Check Images
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
@ -205,23 +159,11 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- uses: actions/setup-node@v2 - run: tar xvf site.tar
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check HTML - name: Check HTML
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
@ -235,31 +177,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2 - name: Validate HTML
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check HTML
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
directory: ${{ github.workspace }}/_site directory: ${{ github.workspace }}/_site
@ -272,31 +195,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2 - name: Validate HTML
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check HTML
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
directory: ${{ github.workspace }}/_site directory: ${{ github.workspace }}/_site
@ -309,31 +213,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2 - name: Validate HTML
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check HTML
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
directory: ${{ github.workspace }}/_site directory: ${{ github.workspace }}/_site
@ -346,31 +231,12 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: ruby/setup-ruby@v1 - name: Download generated Jekyll site
uses: actions/download-artifact@v2
with: with:
bundler-cache: true name: generated-site
- name: Cache node modules - run: tar xvf site.tar
uses: actions/cache@v2 - name: Check OpenGraph
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Cache Jekyll build
uses: actions/cache@v2
with:
path: |
.jekyll-cache
.sass-cache
key: ${{ runner.os }}-jekyll-${{ hashFiles('**/*.??m[ld]') }}
restore-keys: |
${{ runner.os }}-jekyll-
- name: Build website
uses: ./.github/actions/build
- name: Check HTML
uses: chabad360/htmlproofer@v1.1 uses: chabad360/htmlproofer@v1.1
with: with:
directory: ${{ github.workspace }}/_site directory: ${{ github.workspace }}/_site