Skip to content

Commit

Permalink
add schedule action to update website
Browse files Browse the repository at this point in the history
  • Loading branch information
cofiem committed Jul 1, 2024
1 parent 4b99c20 commit d6a5d60
Show file tree
Hide file tree
Showing 3 changed files with 101 additions and 30 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/pages-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Deploy Website scheduled

on:
schedule:
# At 10:00 on Monday.
- cron: '0 10 * * 1'

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false

jobs:

# Build and upload the GitHub Pages artifact.
build:
runs-on: ubuntu-latest
needs:
- recent-redbox-release
- static-files
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
# runs 'bundle install' and caches installed gems automatically
bundler-cache: true
# Increment this number if you need to re-download cached gems
cache-version: 0

- name: Setup Pages
uses: actions/[email protected]

# Generate an include file showing details for
# the latest ReDBox release.
- name: Create latest ReDBox release details if not cached
run: .support/generate_latest_release_info.sh

# Update the static website files
- uses: actions/[email protected]
with:
node-version: 20
cache: 'npm'

- name: Update the static files
run: .support/update_static_files.sh

- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build
env:
JEKYLL_ENV: production

- name: Upload artifact
uses: actions/[email protected]

# Deployment job
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/[email protected]
44 changes: 20 additions & 24 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,35 +24,39 @@ concurrency:
cancel-in-progress: false

jobs:
# Generate an include file showing details for
# the latest ReDBox release.
recent-redbox-release:

# Build and upload the GitHub Pages artifact.
build:
runs-on: ubuntu-latest
needs:
- recent-redbox-release
- static-files
steps:
- name: Checkout
uses: actions/[email protected]

- name: Cache ReDBox latest release files
id: cache-redbox-latest-release-file
# Generate an include file showing details for
# the latest ReDBox release.
- name: Cache modified files
id: cache-modified-files
uses: actions/[email protected]
env:
cache-name: cache-redbox-latest-release-file
cache-name: cache-modified-files
with:
path: |
.support/rblatest.json
_includes/latest_release.html
key: cache-redbox-latest-release-file
static/js/bootstrap.bundle.min.js
static/css/bootstrap.min.css
static/css/bootstrap-icons.min.css
static/css/fonts/bootstrap-icons.woff
static/css/fonts/bootstrap-icons.woff2
key: cache-modified-files

- if: ${{ steps.cache-redbox-latest-release-file.outputs.cache-hit != 'true' }}
name: Create latest ReDBox release details if not cached
run: .support/generate_latest_release_info.sh

static-files:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- uses: actions/[email protected]
with:
node-version: 20
Expand All @@ -61,16 +65,6 @@ jobs:
- name: Update the static files
run: .support/update_static_files.sh

# Build and upload the GitHub Pages artifact.
build:
runs-on: ubuntu-latest
needs:
- recent-redbox-release
- static-files
steps:
- name: Checkout
uses: actions/[email protected]

- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
Expand All @@ -85,11 +79,12 @@ jobs:

- name: Build with Jekyll
# Outputs to the './_site' directory by default
run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}"
run: bundle exec jekyll build
env:
JEKYLL_ENV: production

- name: Upload artifact
if: ${{ ! startsWith(github.ref, 'refs/heads/dependabot') }}
uses: actions/[email protected]

# Deployment job
Expand All @@ -99,6 +94,7 @@ jobs:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
if: ${{ ! startsWith(github.ref, 'refs/heads/dependabot') }}
steps:
- name: Deploy to GitHub Pages
id: deployment
Expand Down
10 changes: 4 additions & 6 deletions .support/generate_latest_release_info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ set -euo pipefail
DATA_FILE=.support/rblatest.json
HTML_FILE=_includes/latest_release.html

if [ ! -f "${DATA_FILE}" ]; then
curl --silent -L -o "${DATA_FILE}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/redbox-mint/redbox-portal/releases/latest
fi
curl --silent -L -o "${DATA_FILE}" \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/redbox-mint/redbox-portal/releases/latest

VERSION=$(jq -r '.tag_name' "${DATA_FILE}")
URL=$(jq -r '.html_url' "${DATA_FILE}")
Expand Down

0 comments on commit d6a5d60

Please sign in to comment.