Skip to content

Commit

Permalink
Maybe fix actions (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
alanocallaghan authored Apr 4, 2024
1 parent 7a63ae0 commit fb892c8
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: Website
on:
push:
branches:
# - gh-pages
- main
pull_request: []

Expand All @@ -13,7 +12,7 @@ jobs:
steps:

- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v2
Expand All @@ -30,9 +29,24 @@ jobs:
ghcr.io/${{ github.repository }}:${{ github.sha }}
ghcr.io/${{ github.repository }}:latest
check:
needs: container
runs-on: ubuntu-latest
container: ghcr.io/${{github.repository}}:latest
defaults:
run:
shell: bash
steps:
- name: Checkout github pages
uses: actions/checkout@v4
- name: Build site
run: |
make site
build-website:
needs: container
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main'}}
container: ghcr.io/${{github.repository}}:latest
env:
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"
Expand All @@ -44,42 +58,32 @@ jobs:

steps:

- name: Checkout the lesson
uses: actions/checkout@v3
- name: Checkout github pages
uses: actions/checkout@v4
with:
ref: gh-pages
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: Set up git
run: |
git config --global --add safe.directory /__w/${{ github.event.repository.name }}/${{ github.event.repository.name }}
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
- name: Merge
run: |
git fetch origin
git merge origin/main
- name: Render the markdown and confirm that the site can be built
run: make site

- name: Checkout github pages
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main'}}
uses: actions/checkout@master
with:
ref: gh-pages
path: gh-pages

- name: Commit and Push
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main'}}
run: |
# clean up gh-pages (source: https://github.com/zkamvar/styles/blob/ed29df30623a68ae87e05811a01283f0452fae4e/.github/workflows/website.yml)
cd gh-pages
git rm -rf . # remove all previous files
git restore --staged . # remove things from the stage
cd ..
# copy everything into gh-pages site
cp -r `ls -A | grep -v 'gh-pages' | grep -v '.git' | grep -v '.bundle/' | grep -v '_site'` gh-pages
# move into gh-pages, add, commit, and push
cd gh-pages
# setup git
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
rm -r _site
git add -A .
git commit --allow-empty -m "[Github Actions] render website (via ${{ github.sha }})"
git push origin gh-pages
# return
cd ..
- run: make lesson-check-all
if: always()

0 comments on commit fb892c8

Please sign in to comment.