Skip to content

Issues if DESTINATION is set to a different directory than SOURCE #199

@kfranqueiro

Description

@kfranqueiro

I have been experimenting with setting DESTINATION to a different directory, with the goal of making usage with actions/upload-pages-artifact@v3 and actions/deploy-pages@v4 as straightforward as possible.

The goal is for something like the following to work:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout git repository
        uses: actions/checkout@v4
      - name: Run spec-prod
        uses: w3c/spec-prod@v2
        with:
          SOURCE: index.html
          DESTINATION: _site/index.html
      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3

  deploy:
    needs: build
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

In the above example, DESTINATION is set to the _site directory, which is the default subdirectory that upload-pages-artifact uses. The goal of this is to only upload what spec-prod has output, without the rest of the source files.

Unfortunately, 2 problems occur...

Local dependencies missing from artifact

Local dependencies are not copied correctly - e.g., if the spec-prod-result artifact should ordinarily contain index.html plus a couple of images if DESTINATION weren't set in this way, now it only contains index.html.

I am wondering if this copyLocalAssets call is the cause, which references rootDir as opposed to destinationDir which is referenced in the subsequent downloadRemoteAssets call:

spec-prod/src/build.ts

Lines 138 to 142 in 215b1bd

await copyLocalAssets(assets.local, rootDir);
const newRemoteURLs = await downloadRemoteAssets(
assets.remote,
destinationDir,
);

However, I am unsure how to be confident that change is correct and wouldn't break other things. I see this repo has a test folder with an index.test.ts entry point, but I didn't find any docs for it and I'm unsure how exactly it works, e.g. what document it runs on / if its inputs can be customized.

The specified destination is not populated

If I perform a ls -lR in the same job as spec-prod after it runs, there is nothing in the destination folder. It doesn't even exist if I don't mkdir -p it first; even if I do, it's empty. This is even more confusing as spec-prod also performs a ls -R of the destination directory during the build process, and that at least lists the index.html file (but no local dependencies, due to the issue above).

I haven't yet stumbled upon any leads as to why this would be the case.

Workaround

While not ideal, I can accomplish my goal by not specifying DESTINATION and instead relying on the artifact produced by spec-prod, adding an extra job in the middle to download it and re-upload it as the pages artifact (it cannot be used directly by renaming, as it's not in a format recognized by deploy-pages):

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout git repository
        uses: actions/checkout@v4
      - name: Run spec-prod
        uses: w3c/spec-prod@v2

  upload:
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Download spec-prod-result artifact
        uses: actions/download-artifact@v4
        with:
          name: spec-prod-result
          path: _site
      - name: Upload Pages artifact
        uses: actions/upload-pages-artifact@v3

  deploy:
    needs: upload
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

Examples

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Up next

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions