From 01995be1f4faca272f4a1450f225709f58eb8f49 Mon Sep 17 00:00:00 2001 From: Jonah Aragon Date: Sat, 1 May 2021 16:24:18 -0500 Subject: [PATCH] Create GitHub Action --- .buildrc | 11 ---- .github/actions/build/action.yml | 13 ++++ .github/workflows/production.yml | 35 ++++++++++ .github/workflows/tests.yml | 65 +++++++++++++++++++ _includes/legacy/sections/browser-addons.html | 2 +- _includes/legacy/sections/browser-tweaks.html | 2 +- package.json | 4 +- 7 files changed, 117 insertions(+), 15 deletions(-) delete mode 100755 .buildrc create mode 100644 .github/actions/build/action.yml create mode 100644 .github/workflows/production.yml create mode 100644 .github/workflows/tests.yml diff --git a/.buildrc b/.buildrc deleted file mode 100755 index 7d32d9f3..00000000 --- a/.buildrc +++ /dev/null @@ -1,11 +0,0 @@ -export BUILD_DATE=$(TZ=UTC date "+%Y-%m-%d") -export BUILD_TIME=$(TZ=UTC date "+%H:%M:%S %Z") - -npm install -gem install bundler:2.2.5 -bundle install - -sed -i "s/^ date:.*$/ date: $BUILD_DATE/" _config.yml -sed -i "s/^ time:.*$/ time: $BUILD_TIME/" _config.yml - -JEKYLL_ENV=production bundle exec jekyll build diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 00000000..c5d0dd6a --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,13 @@ +name: 'Build' +description: 'Builds Jekyll Site' +runs: + using: "composite" + steps: + - shell: bash + run: npm install + - shell: bash + 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 + - shell: bash + run: npm run build diff --git a/.github/workflows/production.yml b/.github/workflows/production.yml new file mode 100644 index 00000000..feef4ef4 --- /dev/null +++ b/.github/workflows/production.yml @@ -0,0 +1,35 @@ +name: Production Deploy +concurrency: + group: Production + cancel-in-progress: true + +on: + push: + branches: [ main ] + +env: + FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }} + +jobs: + deploy: + name: Rsync Deploy + runs-on: ubuntu-latest + environment: production + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Build website + uses: ./.github/actions/build + - name: Copy built site to production + run: | + mkdir -p ~/.ssh + echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa + chmod 700 ~/.ssh/id_rsa + ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts + rsync -azP --delete ${{ github.workspace }}/_site/ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:privacyguides.org-deploy diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 00000000..0e296a01 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,65 @@ +name: Code tests + +on: [push, pull_request] + +env: + FONTAWESOME_NPM_AUTH_TOKEN: ${{ secrets.FONTAWESOME_NPM_AUTH_TOKEN }} + +jobs: + deps: + name: "Dependency Install" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: actions/setup-node@v2 + with: + node-version: '14' + - run: npm install + - run: npm run assets:install + + build: + name: "Jekyll Build" + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Build website + uses: ./.github/actions/build + + link: + name: "Broken Hyperlink Check" + runs-on: ubuntu-latest + needs: [deps, build] + + steps: + - uses: actions/checkout@v2 + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: actions/setup-node@v2 + with: + node-version: '14' + - name: Build website + uses: ./.github/actions/build + - name: Copy built site to production + run: | + mv ${{ github.workspace }}/_site /tmp/ + mkdir -p /tmp/src + mv ${{ github.workspace }}/* /tmp/src/ + mkdir -p ${{ github.workspace }}/src + mv /tmp/src/* ${{ github.workspace }}/src/ + mv /tmp/_site ${{ github.workspace }}/ + - name: Hyperlink link checker + uses: untitaker/hyperlink@0.1.15 + with: + args: _site/ --sources src/ diff --git a/_includes/legacy/sections/browser-addons.html b/_includes/legacy/sections/browser-addons.html index 40916777..4fbfedc3 100644 --- a/_includes/legacy/sections/browser-addons.html +++ b/_includes/legacy/sections/browser-addons.html @@ -1,7 +1,7 @@

Recommended Browser Add-ons

{% include legacy/cardv2.html diff --git a/_includes/legacy/sections/browser-tweaks.html b/_includes/legacy/sections/browser-tweaks.html index 651ceb55..062c2e35 100644 --- a/_includes/legacy/sections/browser-tweaks.html +++ b/_includes/legacy/sections/browser-tweaks.html @@ -127,7 +127,7 @@

Related Information