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
287 stars 46 forks source link

Error when setting action version via SHA #67

Closed vorburger closed 11 months ago

vorburger commented 1 year ago

In https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20 I ran into this:

Run rossjrw/pr-preview-action@183082fd714654433c8e2f6daedbfb4f20f2a94a
  with:
    source-dir: BUILT/site/
    deploy-repository: www-learn-study/previews
    preview-branch: gh-pages
    umbrella-dir: pr-preview
    action: auto
Run echo "action=$action" >> $GITHUB_ENV
  echo "action=$action" >> $GITHUB_ENV
  echo "targetdir=$umbrella/pr-$pr" >> $GITHUB_ENV
  echo "pr=$pr" >> $GITHUB_ENV

  org=$(echo "$deployrepo" | cut -d "/" -f 1)
  thirdleveldomain=$(echo "$deployrepo" | cut -d "/" -f [2](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:2))

  if [ ! -z "$customurl" ]; then
    pagesurl="$customurl"
  elif [ "${org}.github.io" == "$thirdleveldomain" ]; then
    pagesurl="${org}.github.io"
  else
    pagesurl=$(echo "$deployrepo" | sed 's/\//.github.io\//')
  fi

  echo "pagesurl=$pagesurl" >> $GITHUB_ENV

  echo "emptydir=$(mktemp -d)" >> $GITHUB_ENV
  echo "datetime=$(date '+%Y-%m-%d %H:%M %Z')" >> $GITHUB_ENV

  echo "actionref=$actionref" >> $GITHUB_ENV
  echo "actionrepo=$actionrepo" >> $GITHUB_ENV
  echo "deployrepo=$deployrepo" >> $GITHUB_ENV
  echo "token=$token" >> $GITHUB_ENV
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    action: auto
    umbrella: pr-preview
    pr: 20
    actionref: 18[3](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:3)082fd71[4](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:4)6[5](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:5)4433c8e2f[6](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:6)daedbfb4f20f2a94a
    actionrepo: rossjrw/pr-preview-action
    customurl: 
    deployrepo: www-learn-study/previews
    token: 
Run action_version=$("$GITHUB_ACTION_PATH/lib/find-current-git-tag.sh" -p $actionrepo -f $actionref)
  action_version=$("$GITHUB_ACTION_PATH/lib/find-current-git-tag.sh" -p $actionrepo -f $actionref)
  echo "action_version=$action_version" >> "$GITHUB_ENV"
  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
  env:
    action: auto
    targetdir: pr-preview/pr-20
    pr: 20
    pagesurl: www-learn-study.github.io/previews
    emptydir: /tmp/tmp.bCj8nD[7](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:7)DOE
    datetime: 2023-11-02 06:39 UTC
    actionref: 1[8](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:9)3082fd714654433c8e2f6daedbfb4f20f2a[9](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:10)4a
    actionrepo: rossjrw/pr-preview-action
    deployrepo: www-learn-study/previews
    token: 
Determining Git tag for rossjrw/pr-preview-action/183082fd7[14](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:15)654433c8e2f6daedbfb4f20f2a94a
Cloning repository rossjrw/pr-preview-action at ref [18](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:19)3082fd714654433c8e2f6daedbfb4f[20](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:21)f2a94a
Cloning into bare repository 'bare_pr_preview'...
warning: Could not find remote branch 183082fd714654433c8e2f6daedbfb4f20f2a94a to clone.
fatal: Remote branch 183082fd714654433c8e2f6daedbfb4f20f2a94a not found in upstream origin
/home/runner/work/_actions/rossjrw/pr-preview-action/183082fd714654433c8e2f6daedbfb4f20f2a94a/lib/find-current-git-tag.sh: line [29](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6729181929/job/18289629833?pr=20#step:5:30): cd: bare_pr_preview: No such file or directory
Error: Process completed with exit code 1.
vorburger commented 1 year ago

Is this possibly caused by https://github.com/rossjrw/pr-preview-action/commit/aa0f798d7a8862266c793affdfd62ad96edd14d9 & Co?

Why does your action have fancy code to find its own revision? That's curious / interesting - doesn't GitHub check-out the actions?

Or is this not failing to clone the action, but the repo? The "source" or the "target" deploy-repository one?

vorburger commented 1 year ago

Apparently the change I made in https://github.com/www-learn-study/saraswati.learn.study/commit/8e058c4460c6582eea099af5e287c0bfac275018 was the culprit causing this?!

Reverting that in https://github.com/www-learn-study/saraswati.learn.study/pull/55 seems to do the trick (but makes https://github.com/www-learn-study/saraswati.learn.study/issues/50 re-appear, but that's another story).

That using a verion tag instead of a SHA fixes this seems really weird, to me... no action should prevent me from using a SHA (which is considered more secure) instead of a Tag!

rossjrw commented 1 year ago

Why does your action have fancy code to find its own revision? That's curious / interesting - doesn't GitHub check-out the actions?

It's to display the specific action version in the message with the preview link. E.g. if you use rossjrw/pr-preview-action@v1, I feel that it's more useful for the message to show 'v1.2.1' or whatever instead of just 'v1'.

no action should prevent me from using a SHA (which is considered more secure) instead of a Tag!

You're right, and in fact, this was already fixed in https://github.com/rossjrw/pr-preview-action/pull/36. But since then, I've managed to accidentally remove that fallback in https://github.com/rossjrw/pr-preview-action/commit/aa0f798d7a8862266c793affdfd62ad96edd14d9. This one's on me.

rossjrw commented 11 months ago

Fixed in v1.4.6