add ols-values.md draft on website #89
Workflow file for this run
This file contains hidden or 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: Deploy Preview for Pull Requests # Name of this workflow, shown in the GitHub Actions UI | |
on: | |
pull_request: # Run this workflow whenever a Pull Request (PR) is made... | |
branches: | |
- main # ...only if the PR targets the 'main' branch | |
workflow_dispatch: # Allow manual trigger of workflow from "Actions" tab | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest # Use the latest Ubuntu virtual machine | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 # Step 1: Get (clone) the repository code. | |
- name: Set up Ruby # Step 2: Set up Ruby for the runner. | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3.1 # Use Ruby version 3.1 | |
bundler-cache: true # Cache Ruby gems for quicker builds | |
- name: Install dependencies # Step 3: Install all Ruby packages required for the site. | |
run: | | |
bundle install | |
- name: Build Jekyll site # Step 4: Build the site with Jekyll, and put it in '_site' directory. | |
run: | | |
bundle exec jekyll build --destination _site | |
# Step 5: Clone existing gh-pages branch. This preserves previously deployed PR previews. | |
- name: Clone existing gh-pages branch | |
run: | | |
git config --global user.name 'github-actions' | |
git config --global user.email '[email protected]' | |
git clone --depth 1 --branch gh-pages https://x-access-token:${{ secrets.PR_PREVIEW_TOKEN }}@github.com/open-life-science/ols-site-preview.git gh-pages | |
env: | |
GIT_TERMINAL_PROMPT: 0 | |
# Step 6: Copy the built site into the PR folder, so every PR has its own preview. | |
- name: Copy built site into PR folder | |
run: | | |
pr_number=${{ github.event.pull_request.number }} | |
mkdir -p gh-pages/$pr_number | |
rm -rf gh-pages/$pr_number/* | |
cp -r _site/* gh-pages/$pr_number/ | |
- name: Push updated preview site | |
run: | | |
cd gh-pages | |
git add . | |
git commit -m "Deploy preview for PR #${{ github.event.pull_request.number }}" | |
git push origin gh-pages | |
- name: Comment with preview URL | |
env: | |
GITHUB_TOKEN: ${{ secrets.PR_PREVIEW_TOKEN }} # Step 7a: Use token for authentication. | |
run: | # Step 7b: Create a preview URL using the PR number, post a comment with the preview link on this PR. | |
PREVIEW_URL="https://we-are-ols.org/ols-site-preview/${{ github.event.pull_request.number }}/" | |
COMMENT_BODY="🎉 A preview of this PR is available at: [${PREVIEW_URL}](${PREVIEW_URL})" | |
gh pr comment ${{ github.event.pull_request.number }} --body "$COMMENT_BODY" |