Build with full git history, unshallow clone
J
Johannes Rudolph
Our builds seem to run on a shallow git clone i.e.
git fetch --depth=1
.I verified this by running the following build command
Oct. 31 05:25:25 PM ==> Running build command 'git --version && git rev-parse --is-shallow-repository && yarn docs:build'...
Oct. 31 05:25:25 PM git version 2.20.1
Oct. 31 05:25:25 PM true
This is a problem for our static site build using vuepress (or docusaurus) because they both use git history information to autogenerate last edit information for pages by querying the git repo's history for the file. This history is not available in shallow clones.
Now, I tried unshallowing in the build command but somehow it seems that's blocked (silently fails to do its job) in the CI environment
Oct. 31 05:39:23 PM ==> Running build command 'git --version && git rev-parse --is-shallow-repository && git fetch --unshallow && git rev-parse --is-shallow-repository && yarn docs:build'...
Oct. 31 05:39:23 PM git version 2.20.1
Oct. 31 05:39:23 PM true
Oct. 31 05:39:23 PM true
Is there any way I can get the render build runners to run a CI build with a full clone of the git repo?
Log In
D
Dan Croak
I have the same use case and problem. I have a custom static generator written in Go that uses a file's Git history to generate the article's last updated date:
exec.Command("git", "log", "-1", "--format=%cd", "--date=format:%B %d, %Y", "--", "articles/"+f.Name())
If
git fetch --unshallow
were unblocked for static site build commands, that would resolve my issue as I'd be able to run git fetch --unshallow && go run main.go build
as my build command.D
Dan Croak
An alternate solution would be to offer a different kind of deploy hook or a Render GitHub Action that uploads the publish directory.
Hypothetical GitHub Action interface:
name: deploy
jobs:
deploy:
name: deploy
runs-on: ubuntu-latest
permissions:
contents: read # Needed to clone the repository
steps:
- name: Clone repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.pull_request.head.sha }} # Needed for correct "Last updated" dates
fetch-depth: 0
- name: Build site
shell: bash
run: go run main.go build # Generates static files to "public" directory
- name: Upload to Render
uses: renderinc/staticdeploy@v1
with:
service_name: ${{ secrets.RENDER_SERVICE_NAME }}
publish_directory: public