Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maybe fix actions #181

Merged
merged 9 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()