Skip to content

Commit

Permalink
Publish & Preview Workflows + MLG Navbar & Footer! (#6)
Browse files Browse the repository at this point in the history
* Added navbar similar to MLG site in blog

* Added Anaheim font only for navbar!

* Minor styling updates

* Added footer and modified a header a bit

* Update default.html

* Update default.html

* Update default.html

* Create jekyll-docker.yml

* Create jekyll.yml

* Delete .github/workflows/jekyll.yml

* Update jekyll-docker.yml

* Update jekyll-docker.yml

* Update jekyll-docker.yml

* Update jekyll-docker.yml

* Update jekyll-docker.yml

* Update Gemfile.lock

* Update _config.yml

* Update and rename jekyll-docker.yml to publish.yml

* Create preview.yml

* Update preview.yml

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update _config.yml

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update default.html

* Update template.scss

* Update default.html

* Update default.html

* Update default.html

* cleaned code
  • Loading branch information
shravanngoswamii authored Oct 2, 2024
1 parent 8419e6e commit e2fccf2
Show file tree
Hide file tree
Showing 7 changed files with 339 additions and 34 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Jekyll PR Preview Workflow

on:
workflow_dispatch:
pull_request_target:
types: [opened, synchronize, closed]

jobs:
build-and-preview:
if: github.event.action == 'opened' || github.event.action == 'synchronize'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'

- name: Install dependencies
run: |
gem install bundler
bundle install
- name: Build the site
run: bundle exec jekyll build --future

- name: Deploy to GitHub Pages
uses: jamesives/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: _site
target-folder: pr-previews/${{ github.event.pull_request.number }}
clean: false
commit-message: Deploy preview for PR ${{ github.event.pull_request.number }}
token: ${{ secrets.GITHUB_TOKEN }}

comment-preview-url:
needs: build-and-preview
if: needs.build-and-preview.result == 'success'
runs-on: ubuntu-latest
steps:
- name: Comment Preview URL
uses: thollander/actions-comment-pull-request@v2
with:
message: |
<!-- preview-url-comment -->
Preview the changes: https://mlg.eng.cam.ac.uk/blog/pr-previews/${{ github.event.pull_request.number }}
comment_tag: preview-url-comment
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

delete-preview-directory:
if: github.event.action == 'closed' || github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages

- name: Remove PR Preview Directory
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
PREVIEW_DIR="pr-previews/${PR_NUMBER}"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git pull origin gh-pages
rm -rf ${PREVIEW_DIR}
git add .
git commit -m "Remove preview for merged PR #${PR_NUMBER}"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34 changes: 34 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Jekyll Site CI

on:
push:
branches:
- main
workflow_dispatch: # manual trigger for testing

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'

- name: Install dependencies
run: |
gem install bundler
bundle install
- name: Build the site
run: bundle exec jekyll build --future

- name: Deploy to GitHub Pages
uses: jamesives/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: _site
clean: false
1 change: 1 addition & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ GEM
PLATFORMS
arm64-darwin-21
x86_64-darwin-19
x86_64-linux

DEPENDENCIES
jekyll (= 3.9)
Expand Down
1 change: 0 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ exclude:
- LICENSE.txt
- README.md
- todo.tasks

2 changes: 2 additions & 0 deletions _includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/h5bp.css">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/solarized-light.css">
<link rel="stylesheet" href="{{ site.baseurl }}/assets/css/style.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Anaheim">

{% include preload_images.html %}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<script type="text/javascript" src="{{ site.baseurl }}/assets/links.js"></script>


<script type="text/javascript">
page_url = "{{ page.url | prepend: site.url }}"
Expand Down
Loading

0 comments on commit e2fccf2

Please sign in to comment.