JamesIves/github-pages-deploy-action

bug: ๐Ÿ action incorrectly reports nothing to commit

lucascolley opened this issue ยท 3 comments

Describe the bug

EDIT: updated to the correct link

https://github.com/data-apis/array-api-extra/actions/runs/11108938259 shows this action saying that There is nothing to commit, when changes were in fact made to the docs.

Reproduction Steps

see above workflow run

Logs

No response

Workflow

name: Docs Deploy

on:
  push:
    branches:
      - main

jobs:
  docs-deploy:
    runs-on: ubuntu-latest
    environment:
      name: docs-deploy
    steps:
      - uses: actions/checkout@v4
      - name: Download Artifact
        uses: dawidd6/action-download-artifact@v6
        with:
          workflow: docs-build.yml
          name: docs-build
          path: docs/build/

      # Note, the gh-pages deployment requires setting up a SSH deploy key.
      # See
      # https://github.com/JamesIves/github-pages-deploy-action/tree/dev#using-an-ssh-deploy-key-
      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: docs/build/
          ssh-key: ${{ secrets.DEPLOY_KEY }}
          force: yes

Additional Comments

No response

You are likely encountering a race condition here. When I look at your workflows, both the build and deploy trigger from the same event (push), meaning that it may be downloading a stale artifact and thus finding that there's nothing to deploy depending on which one finishes first.

You may want to re-arrange your workflows to combine the build + deploy job, or run them both independently, ie build your docs, and then deploy them in the same job. You could also use a workflow_call, or something to signify that the build job has finished before the other one runs, but that may be overkill for this use case.

Something like this:

name: Docs Deploy

on:
  push:
    branches:
      - main

jobs:
  docs-build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: prefix-dev/setup-pixi@v0.8.1
        with:
          pixi-version: v0.30.0
          cache: true
      - name: Build Docs
        run: pixi run -e docs docs

      - name: Deploy
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: docs/build/  # Not sure if this is the correct directory or not
          ssh-key: ${{ secrets.DEPLOY_KEY }}

thanks for the quick response @JamesIves ! Sounds plausible, will give it a go.

Yep it was a race condition, thanks again @JamesIves ! Fixed with this diff

diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml
index 59845b0..5ba6577 100644
--- a/.github/workflows/docs-deploy.yml
+++ b/.github/workflows/docs-deploy.yml
@@ -1,13 +1,16 @@
 name: Docs Deploy
 
 on:
-  push:
+  workflow_run:
+    workflows: ["Docs Build"]
+    types: [completed]
     branches:
-      - main
+      - "main"
 
 jobs:
   docs-deploy:
     runs-on: ubuntu-latest
+    if: ${{ github.event.workflow_run.event == 'push' }}
     environment:
       name: docs-deploy
     steps:
@@ -27,4 +30,3 @@ jobs:
         with:
           folder: docs/build/
           ssh-key: ${{ secrets.DEPLOY_KEY }}
-          force: yes