Skip to content
This repository has been archived by the owner on Jul 5, 2021. It is now read-only.

Add automatically scheduled theme updates #259

Closed
digitalcraftsman opened this issue May 21, 2017 · 17 comments
Closed

Add automatically scheduled theme updates #259

digitalcraftsman opened this issue May 21, 2017 · 17 comments
Labels

Comments

@digitalcraftsman
Copy link
Member

digitalcraftsman commented May 21, 2017

The current approach requires a manual update of the submodules that reference the themes. A cron job or a similar tool could alternatively update the theme list automatically in a predefined interval, e.g. once a day.

This way theme maintainers aren't dependent on the current, unplanned (but still regular) update cycle.

As suggested by @MunifTanjim in this comment.

@MunifTanjim
Copy link

Maybe something like this?

git clone --depth 1 https://github.com/spf13/hugoThemes
git submodule update --init --remote
git commit -am "updated themes at $(date +"%Y-%m-%d %H:%M")"
git push

Travis CI now has corn job support. It can run daily. It will pull all latest changes and push it to the repo. That should trigger a build.

@ghost
Copy link

ghost commented May 22, 2017

I consider my theme master "mostly stable", and use SemVer and Git tags with a changelog generator whenever I have noteworthy updates. I've seen some others following the same approach.

@ghost
Copy link

ghost commented May 22, 2017

@paskal
Copy link

paskal commented Mar 22, 2018

Travis CI now has corn job support.

image

@felicianotech
Copy link

This can be implemented with CircleCI. Just let me know.

@onedrawingperday
Copy link
Contributor

onedrawingperday commented Oct 6, 2019

@orf posted about Dependabot in another pull request

This is a free service that has been acquired by GitHub and it provides a way to create pull requests when submodules are updated (once a day or once a week).

This is not a fully automatic theme update since in the end a human needs to review and merge these Pull Requests.

It would still save time though since it would remove the need to maintain a local clone with every theme in the repo.

Anyway maybe we should investigate if it's possible to use Dependabot in this repo.

cc: @digitalcraftsman @bep

@digitalcraftsman
Copy link
Member Author

I've been testing Dependabot using my fork of this repo.

Submodules can be updated on a daily or weekly basis. One "issue" I see is that Dependabot creates a new pull request for each updated submodule. This can get quite noise after a while. The grouping of pull requests is still an open feature request. I suggest to schedule the updates weekly.

Furthermore, Dependabot allows you to auto-merge pull request if they match certain rules (i.e. only merge security updates etc.). Dependabots pull requests don't need to be approved or reviewed. Having them auto-merged means @onedrawingperday and I don't have to merge them manually. But I still have to get that working.

@digitalcraftsman
Copy link
Member Author

digitalcraftsman commented Oct 9, 2019

Update: Automerge works but is not performed because Dependabot detected that we use Netlify as CI-service. This can be deactivated in the config file found at .dependabot/config.yml in my fork of this repo.

A while ago Netlify started to charge for build minutes. They granted us a special open-source plan for pricing that likely excludes us and no credit cards are deposited. But it is still inefficient to rebuild the theme site with each updated theme / pull request.

@orf
Copy link
Contributor

orf commented Oct 9, 2019

Perhaps it could be modified to only build the site with a single theme (the one being updated) in pull requests?

@digitalcraftsman
Copy link
Member Author

Are you referring to the build script for the Hugo theme site?

@orf
Copy link
Contributor

orf commented Oct 9, 2019

Yes, in a pull request you could build the hugo theme site with a single theme, the one being updated. That would be a lot faster and give you reasonable confidence that merging this won't suddenly break the entire build.

@digitalcraftsman
Copy link
Member Author

Right now the build script does not support "incremental" builds. Unfortunately it's all or nothing that gets rebuild. Netlify already caches the submodules (themes) but the Hugo theme site still gets rebuild in its entirety.

@onedrawingperday
Copy link
Contributor

Oh I see... thanks for looking into Dependabot @digitalcraftsman

A PR per updated submodule is not ideal. It will clutter the repo’s history and waste Netlify’s Open Source plan.

It’s a shame that Dependabot cannot include all updates in a single PR.

@onedrawingperday
Copy link
Contributor

onedrawingperday commented Nov 8, 2019

@digitalcraftsman

I have some great news.

On my fork of the Hugo themes I was able to update all theme submodules with GitHub Actions.

Best of all the GitHub Actions bot can be scheduled to run automatically with POSIX cron syntax:

To schedule a workflow, you can use the POSIX cron syntax in your workflow file. The shortest interval you can run scheduled workflows is once every 5 minutes. For example, this workflow is triggered every hour.

on:
 schedule:
   - cron:  '0 * * * *'

(quote from here)


Here is the full log of the automated themes updated on my fork.

Here is the commit with the automated Themes Update.

Here are the contents of my .github/workflows/themesUpdate.yml

name: Themes Update
on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Prepare repository
      run: | 
        git config --global user.email "onedrawingperday@users.noreply.github.comm"
        git config --global user.name "onedrawingperday"
        git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
        git checkout "${GITHUB_REF:11}"
    - name: Update Submodules
      run: |
        git submodule init && git submodule update --recursive --remote && git add . && git commit -am "Update Themes"
        git push --force-with-lease

Notes:

  • At the moment I am triggering this whenever there is a push for testing purposes.
  • GitHub Actions leave the repo with a detached HEAD state as mentioned in this issue therefore to be able to apply changes and push them the git checkout "${GITHUB_REF:11}" workaround is needed until this issue is resolved.

I think that if we enable this in the repo it will make our lives much easier.
I propose that we configure the updates every 3 days or so.
Feel free to amend everything above as you see fit.
Looking forward to finally closing this issue.
Let me know if I can help in any other way.

@onedrawingperday
Copy link
Contributor

@digitalcraftsman
When I synced the repo with the updated themes the workflow YAML was also included in this repo at https://github.com/gohugoio/hugoThemes/tree/master/.github/workflows

So that is the file to you may want to amend.

onedrawingperday added a commit that referenced this issue Nov 8, 2019
onedrawingperday added a commit that referenced this issue Nov 8, 2019
@onedrawingperday
Copy link
Contributor

@digitalcraftsman

With commit 6e48377 I scheduled the Theme Updates to run:
Runs at 00:00 UTC on the 1, 4, 7, 10, 13, 16, 19, 22, 25, 28 and 31th of every month

If everything I've done is fine, then this issue can be closed.

@onedrawingperday
Copy link
Contributor

Themes were updated automatically and on schedule with commit da06a61 🚀

This issue is resolved.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants