rossjrw / pr-preview-action

GitHub Action that deploys a pull request preview to GitHub Pages, similar to Vercel and Netlify, and cleans up after itself.
https://github.com/marketplace/actions/deploy-pr-preview
MIT License
255 stars 39 forks source link

Can this run in a container? Getting error #43

Closed predominant closed 1 year ago

predominant commented 1 year ago

I'm trying to run this action in a container like below:

name: Deploy PR previews

on:
  pull_request:
    types:
      - opened
      - reopened
      - synchronize
      - closed

concurrency: preview-${{ github.ref }}

jobs:
  deploy-preview:
    runs-on: [ self-hosted ]
    container: artifactory.mycompany.com/swr-docker-release/build-image/base:stable
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: 14.17.0

      - name: Yarn install
        uses: borales/actions-yarn@v4
        with:
          cmd: install
          dir: ./app

      - name: Build production bundle
        uses: borales/actions-yarn@v4
        with:
          cmd: build
          dir: ./app

      - name: Deploy preview
        uses: rossjrw/pr-preview-action@v1
        with:
          source-dir: ./app/dist/

Note that this uses the container option with an artifactory URI to grab the image.

The following error is encountered:

Run /home/myuser/runners/01/_work/_actions/rossjrw/pr-preview-action/v1/lib/find-current-git-tag.sh -p $actionrepo -f $actionref
  /home/myuser/runners/01/_work/_actions/rossjrw/pr-preview-action/v1/lib/find-current-git-tag.sh -p $actionrepo -f $actionref
  shell: bash --noprofile --norc -e -o pipefail {0}
  env:
    action: auto
    targetdir: pr-preview/pr-232
    pr: 232
    pagesurl: swr.github.io/sre-portal
    emptydir: /tmp/tmp.GEsaOyeWhF
    datetime: 2023-04-26 05:10 UTC
    actionref: v1
    actionrepo: rossjrw/pr-preview-action
    deployrepo: swr/sre-portal
    token: ***
/__w/_temp/0dec96f1-b2e1-4f04-a548-60ec5383fe95.sh: line 1: /home/myuser/runners/01/_work/_actions/rossjrw/pr-preview-action/v1/lib/find-current-git-tag.sh: No such file or directory
rossjrw commented 1 year ago

Looks like this is caused by https://github.com/actions/runner/issues/716

There's a hacky-looking user-end workaround described in that issue: https://github.com/actions/runner/issues/716#issuecomment-848391951, but looks like there's a simpler one on the action end.

@predominant Could you try rossjrw/pr-preview-action@f384107658e4c8979be0fad53dc61657c1d00dae and let me know if that works?

predominant commented 1 year ago

This works great. Thanks for the fix!

I have other questions but I'll open another issue for that.

rossjrw commented 1 year ago

Thanks @predominant. Noting that this is now released as of v1.4.1, so you can switch back to rossjrw/pr-preview-action@v1 and get the fix.