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

Simplify GitHub Actions #18

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
34 changes: 9 additions & 25 deletions .github/workflows/build-and-publish-documentation.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
rmarkdown::render("docs/real-time-method-comparison/index.Rmd")
shell: Rscript {0}

- name: Render paper
run: |
rmarkdown::render("writeup/paper.Rmd", output_dir = "docs")
Expand All @@ -62,27 +62,11 @@ jobs:
retention-days: 5
path: docs

publish-documentation:
if: github.ref == 'refs/heads/main' && github.repository == 'epiforecasts/eval-germany-sp-nowcasting'
needs: render-documentation
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- name: Make a clean gh-pages branch
run: |
git checkout --orphan gh-pages
git rm -rf .
- uses: actions/download-artifact@v2
with:
name: documentation
path: .
- name: Commit and push documentation
run: |
git config user.email "action@github.com"
git config user.name "GitHub Action - Published documentation"
git add --all
git commit -m "Published documentation"
git push -f origin gh-pages:gh-pages
echo "reports published to GitHub"
- name: Deploy to GitHub pages 🚀
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obviously much cleaner but the bit it loses is the ability to inspect docs etc generated by branches other than main which is quite nice when making edits. Is there a way to do that with this action?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, missed this. As it is, it would redeploy on pushes to any branch, which is probably not what you want.

I would test things locally. I'm not sure there is a huge benefit to do it via GitHub Actions. Am I missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly that I don't want to test things locally 😆

Also very handy for collabs etc where they may not have the dev environment and/or may not post what the updated text looks like.

if: github.ref == 'refs/heads/main'
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: gh-pages
folder: docs
single-commit: true
clean: true
11 changes: 5 additions & 6 deletions .github/workflows/build-and-push-image.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

concurrency:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah this is awesome - thanks

group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-push-image:
runs-on: ubuntu-latest
Expand All @@ -17,11 +21,6 @@ jobs:

steps:

- name: Cancel previous builds if present
uses: n1hility/cancel-previous-runs@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repository
uses: actions/checkout@v2

Expand All @@ -45,4 +44,4 @@ jobs:
file: ./.devcontainer/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}