Giter Site home page Giter Site logo

rossjrw / pr-preview-action Goto Github PK

View Code? Open in Web Editor NEW
239.0 4.0 39.0 144 KB

GitHub Action that deploys a pull request preview to GitHub Pages, similar to Vercel and Netlify, and cleans up after itself.

Home Page: https://github.com/marketplace/actions/deploy-pr-preview

License: MIT License

Shell 90.90% HTML 9.10%
github-pages github-actions workflow deployment gh-pages actions action pr-preview preview pull-requests

pr-preview-action's Introduction

Welcome to my Github profile! We're playing the Royal Game of Ur. Game #19 is in progress, but you can join!

It's the ⚪white team's turn.

You're on a team! 👋

  • If you've already played a turn this game, you're already on a team — check the game log below for a reminder. If it's not your turn, check back later, or ask a friend to make a move.
  • If you've not yet played a turn this game, make a move now to join the ⚪white team.

⚪White team: You rolled a 1! What would you like to do?

Choices (pick one of them!)
🏵️ Move the piece on tile 3 to tile 4
Move the piece on tile 5 to tile 6
⚔️ Move the piece on tile 8 to tile 9

Game #19 so far

Who's on each team?

Players in this game
Black team White team
@tassiaaccioly (6)
@huuquyet (6)
@CostasAK (3)
@7IronSnow7 (1)
@karim-eg (1)
@chiragyadav916 (1)
@Casper-Guo (20)
@nicolasborromeo (1)
@Baystef (1)

What's happened so far?

Time Turn Event Issue Board
11th Apr 2024 03:01 0 @tassiaaccioly started a new game #2797 link
11th Apr 2024 03:01 1 @tassiaaccioly moved a black piece onto the board to position 2 #2798 link
11th Apr 2024 03:10 2 @Casper-Guo moved a white piece onto the board to position 1 #2799 link
11th Apr 2024 11:51 3 @tassiaaccioly moved a black piece onto the board to position 3 #2800 link
11th Apr 2024 11:56 4 @Casper-Guo moved a white piece from position 1 to position 4 — claimed a rosette 🏵️ #2801 link
11th Apr 2024 11:59 5 @Casper-Guo moved a white piece onto the board to position 2 #2802 link
11th Apr 2024 13:08 6 @7IronSnow7 moved a black piece from position 3 to position 5 #2803 link
11th Apr 2024 13:12 7 @Casper-Guo moved a white piece from position 4 to position 6 #2804 link
11th Apr 2024 13:55 8 @tassiaaccioly moved a black piece from position 5 to position 7 #2805 link
11th Apr 2024 14:13 9 @Casper-Guo moved a white piece onto the board to position 4 — claimed a rosette 🏵️ #2806 link
11th Apr 2024 14:15 10 @Casper-Guo moved a white piece from position 6 to position 7 — captured a black piece ⚔️ #2807 link
11th Apr 2024 23:53 11 @karim-eg moved a black piece from position 2 to position 5 #2808 link
11th Apr 2024 23:59 12 @Casper-Guo moved a white piece from position 7 to position 8 — claimed a rosette 🏵️ #2809 link
12th Apr 2024 00:02 13 @Casper-Guo moved a white piece from position 4 to position 6 #2810 link
14th Apr 2024 18:12 14 @chiragyadav916 moved a black piece from position 5 to position 6 — captured a white piece ⚔️ #2813 link
14th Apr 2024 20:59 15 @Casper-Guo moved a white piece onto the board to position 1 #2814 link
17th Apr 2024 12:33 16 @CostasAK moved a black piece onto the board to position 4 — claimed a rosette 🏵️ #2815 link
17th Apr 2024 12:33 17 @CostasAK moved a black piece from position 6 to position 7 #2816 link
17th Apr 2024 15:59 18 @Casper-Guo moved a white piece from position 2 to position 4 — claimed a rosette 🏵️ #2817 link
17th Apr 2024 16:02 19 @Casper-Guo moved a white piece from position 4 to position 7 — captured a black piece ⚔️ #2818 link
17th Apr 2024 16:50 20 @tassiaaccioly moved a black piece from position 4 to position 7 — captured a white piece ⚔️ #2819 link
17th Apr 2024 17:21 21 @Casper-Guo moved a white piece from position 1 to position 4 — claimed a rosette 🏵️ #2820 link
17th Apr 2024 18:45 22 @Casper-Guo moved a white piece from position 4 to position 6 #2821 link
18th Apr 2024 09:22 23 @CostasAK moved a black piece onto the board to position 3 #2822 link
18th Apr 2024 17:29 24 @Casper-Guo moved a white piece onto the board to position 2 #2823 link
23rd Apr 2024 02:28 25 @huuquyet moved a black piece from position 3 to position 6 — captured a white piece ⚔️ #2824 link
24th Apr 2024 00:49 26 @nicolasborromeo moved a white piece onto the board to position 3 #2825 link
24th Apr 2024 09:40 27 @huuquyet moved a black piece onto the board to position 1 #2826 link
24th Apr 2024 21:12 28 @Casper-Guo moved a white piece from position 2 to position 4 — claimed a rosette 🏵️ #2827 link
24th Apr 2024 21:14 29 @Casper-Guo moved a white piece from position 4 to position 7 — captured a black piece ⚔️ #2828 link
24th Apr 2024 21:28 30 @tassiaaccioly moved a black piece from position 6 to position 7 — captured a white piece ⚔️ #2829 link
24th Apr 2024 22:01 31 @Casper-Guo moved a white piece onto the board to position 2 #2830 link
25th Apr 2024 05:12 32 @huuquyet moved a black piece onto the board to position 2 #2831 link
25th Apr 2024 14:36 33 @Casper-Guo moved a white piece from position 2 to position 4 — claimed a rosette 🏵️ #2832 link
25th Apr 2024 14:43 34 @Casper-Guo moved a white piece onto the board to position 1 #2833 link
26th Apr 2024 05:09 35 @huuquyet moved a black piece from position 2 to position 3 #2834 link
26th Apr 2024 17:19 36 @Baystef moved a white piece onto the board to position 2 #2835 link
27th Apr 2024 02:53 37 @huuquyet moved a black piece from position 3 to position 5 #2836 link
28th Apr 2024 17:44 38 @Casper-Guo moved a white piece from position 4 to position 5 — captured a black piece ⚔️ #2837 link
29th Apr 2024 03:08 39 @huuquyet moved a black piece from position 7 to position 9 #2838
Previous games

Previous games

  1. A game was started on 30th Jul 2020 by @rossjrw and ended on 4th Dec 2020.
    • The ⚪white team won.
    • 64 players played 166 moves across 4 months and 5 days.
    • The ⚫black team captured 9 white pieces and claimed 12 rosettes.
    • The ⚪white team captured 10 black pieces and claimed 18 rosettes.
    • The MVP of the winning team was @1ethanhansen, who played 48 moves.
    • The winning move was made by @qbtl (#269).
  2. A game was started on 4th Dec 2020 by @1ethanhansen and ended on 11th Jan 2021.
    • The ⚫black team won.
    • 27 players played 145 moves across 1 month and 1 week.
    • The ⚫black team captured 7 white pieces and claimed 16 rosettes.
    • The ⚪white team captured 6 black pieces and claimed 14 rosettes.
    • The MVP of the winning team was @shpatrickguo, who played 26 moves.
    • The winning move was made by @shpatrickguo (#424).
  3. A game was started on 11th Jan 2021 by @BaptisteMartinet and ended on 11th Feb 2021.
    • The ⚪white team won.
    • 17 players played 118 moves across 1 month and 12 hours.
    • The ⚫black team captured 2 white pieces and claimed 11 rosettes.
    • The ⚪white team captured 8 black pieces and claimed 14 rosettes.
    • The MVP of the winning team was @1ethanhansen, who played 45 moves.
    • The winning move was made by @1ethanhansen (#535).
  4. A game was started on 11th Feb 2021 by @1ethanhansen and ended on 5th Mar 2021.
    • The ⚪white team won.
    • 17 players played 175 moves across 3 weeks and 22 hours.
    • The ⚫black team captured 12 white pieces and claimed 17 rosettes.
    • The ⚪white team captured 13 black pieces and claimed 18 rosettes.
    • The MVP of the winning team was @1ethanhansen, who played 48 moves.
    • The winning move was made by @1ethanhansen (#702).
  5. A game was started on 6th Mar 2021 by @shpatrickguo and ended on 10th May 2021.
    • The ⚫black team won.
    • 42 players played 162 moves across 2 months and 4 days.
    • The ⚫black team captured 12 white pieces and claimed 17 rosettes.
    • The ⚪white team captured 9 black pieces and claimed 19 rosettes.
    • The MVP of the winning team was @shpatrickguo, who played 22 moves.
    • The winning move was made by @crxssed7 (#864).
  6. A game was started on 10th May 2021 by @HAUDRAUFHAUN and ended on 17th Jul 2021.
    • The ⚪white team won.
    • 34 players played 167 moves across 2 months and 6 days.
    • The ⚫black team captured 7 white pieces and claimed 14 rosettes.
    • The ⚪white team captured 10 black pieces and claimed 18 rosettes.
    • The MVP of the winning team was @1ethanhansen, who played 31 moves.
    • The winning move was made by @1ethanhansen (#1024).
  7. A game was started on 17th Jul 2021 by @1ethanhansen and ended on 19th Oct 2021.
    • The ⚫black team won.
    • 48 players played 153 moves across 3 months and 3 days.
    • The ⚫black team captured 6 white pieces and claimed 17 rosettes.
    • The ⚪white team captured 6 black pieces and claimed 15 rosettes.
    • The MVP of the winning team was @PkmnQ, who played 13 moves.
    • The winning move was made by @OmKakatkar (#1175).
  8. A game was started on 19th Oct 2021 by @OmKakatkar and ended on 29th Oct 2021.
    • The ⚪white team won.
    • 13 players played 135 moves across 1 week and 3 days.
    • The ⚫black team captured 5 white pieces and claimed 13 rosettes.
    • The ⚪white team captured 6 black pieces and claimed 15 rosettes.
    • The MVP of the winning team was @Timemaster111, who played 46 moves.
    • The winning move was made by @Timemaster111 (#1342).
  9. A game was started on 29th Oct 2021 by @jbmagination and ended on 15th May 2022.
    • The ⚪white team won.
    • 80 players played 187 moves across 6 months and 2 weeks.
    • The ⚫black team captured 11 white pieces and claimed 17 rosettes.
    • The ⚪white team captured 13 black pieces and claimed 19 rosettes.
    • The MVP of the winning team was @nirakon, who played 18 moves.
    • The winning move was made by @Madflows (#1534).
  10. A game was started on 15th May 2022 by @VikashPR and ended on 29th Dec 2022.
    • The ⚪white team won.
    • 109 players played 177 moves across 7 months and 2 weeks.
    • The ⚫black team captured 9 white pieces and claimed 23 rosettes.
    • The ⚪white team captured 11 black pieces and claimed 19 rosettes.
    • The MVP of the winning team was @LAPCoder, who played 11 moves.
    • The winning move was made by @LAPCoder (#1726).
  11. A game was started on 29th Dec 2022 by @CostasAK and ended on 30th Dec 2022.
    • The ⚫black team won.
    • 4 players played 121 moves across 19 hours and 41 minutes.
    • The ⚫black team captured 6 white pieces and claimed 14 rosettes.
    • The ⚪white team captured 4 black pieces and claimed 15 rosettes.
    • The MVP of the winning team was @CostasAK, who played 59 moves.
    • The winning move was made by @CostasAK (#1844).
  12. A game was started on 30th Dec 2022 by @TejaTadepalli and ended on 27th Jan 2023.
    • The ⚪white team won.
    • 17 players played 158 moves across 4 weeks and 1 hour.
    • The ⚫black team captured 9 white pieces and claimed 18 rosettes.
    • The ⚪white team captured 12 black pieces and claimed 18 rosettes.
    • The MVP of the winning team was @TejaTadepalli, who played 59 moves.
    • The winning move was made by @TejaTadepalli (#1994).
  13. A game was started on 27th Jan 2023 by @TejaTadepalli and ended on 14th Mar 2023.
    • The ⚪white team won.
    • 20 players played 153 moves across 1 month and 2 weeks.
    • The ⚫black team captured 6 white pieces and claimed 17 rosettes.
    • The ⚪white team captured 6 black pieces and claimed 16 rosettes.
    • The MVP of the winning team was @TejaTadepalli, who played 65 moves.
    • The winning move was made by @TejaTadepalli (#2145).
  14. A game was started on 14th Mar 2023 by @Murdeala and ended on 13th Apr 2023.
    • The ⚪white team won.
    • 19 players played 141 moves across 4 weeks and 1 day.
    • The ⚫black team captured 4 white pieces and claimed 18 rosettes.
    • The ⚪white team captured 12 black pieces and claimed 16 rosettes.
    • The MVP of the winning team was @CostasAK, who played 71 moves.
    • The winning move was made by @CostasAK (#2275).
  15. A game was started on 13th Apr 2023 by @thisiscoding1234 and ended on 7th Jul 2023.
    • The ⚫black team won.
    • 48 players played 122 moves across 2 months and 3 weeks.
    • The ⚫black team captured 11 white pieces and claimed 15 rosettes.
    • The ⚪white team captured 4 black pieces and claimed 9 rosettes.
    • The MVP of the winning team was @Murdeala, who played 37 moves.
    • The winning move was made by @WKL10086 (#2460).
  16. A game was started on 7th Jul 2023 by @kztera and ended on 26th Oct 2023.
    • The ⚪white team won.
    • 38 players played 142 moves across 3 months and 2 weeks.
    • The ⚫black team captured 5 white pieces and claimed 14 rosettes.
    • The ⚪white team captured 12 black pieces and claimed 14 rosettes.
    • The MVP of the winning team was @CostasAK, who played 53 moves.
    • The winning move was made by @CostasAK (#2612).
  17. A game was started on 27th Oct 2023 by @blacksmithop and ended on 3rd Dec 2023.
    • The ⚫black team won.
    • 22 players played 55 moves across 1 month and 6 days.
    • The ⚫black team captured 5 white pieces and claimed 11 rosettes.
    • The ⚪white team captured 0 black pieces and claimed 3 rosettes.
    • The MVP of the winning team was @CostasAK, who played 26 moves.
    • The winning move was made by @CostasAK (#2664).
  18. A game was started on 4th Dec 2023 by @joshuajohncohen and ended on 11th Apr 2024.
    • The ⚫black team won.
    • 44 players played 133 moves across 4 months and 6 days.
    • The ⚫black team captured 11 white pieces and claimed 16 rosettes.
    • The ⚪white team captured 5 black pieces and claimed 12 rosettes.
    • The MVP of the winning team was @CostasAK, who played 49 moves.
    • The winning move was made by @tassiaaccioly (#2796).

👁️ Watch this repository to be the first to know when someone has played

⭐ Star this repository to invite your followers to play


How do I play?

Rules of the game

It's the ⚪white team versus the ⚫black team.

The first team to 🚀ascend all 7 of their pieces 👑wins. Your goal is to achieve that, and to block the other team from doing the same.

(Learn more about the rules of the Royal Game of Ur at RoyalUr.net/learn, or watch Tom Scott play against Irving Finkel in 2017.)

Movement

Each turn starts by rolling 4 binary dice, which results in a number from 0 to 4. The current team gets to move one of their pieces by that many tiles.

All 14 pieces start on position 0 (the space just before tile 1).

🚀Ascension

Moving a piece onto position 15 (the imaginary space after tile 14) causes that piece to leave the board forever. This is 🚀ascension, and is the goal of the game — the first team to ascend all 7 of their pieces wins.

⚔️Capturing

You will move your pieces along the tiles from tile 1 to tile 14.

The tiles on your side of the board (tiles 1 through 4, 13, and 14) are safe — only your pieces can be there. However, the tiles in the middle (tiles 5 through 12) are unsafe — your opponent's pieces can also be here. If one team's piece lands on the same tile as another team's piece, the piece that was landed on is ⚔️captured! It goes all the way back to position 0.

🏵️Rosettes

If a piece lands on a 🏵️rosette (tiles 4, 8, and 14), that team gets to immediately take another turn.

A piece that is on the rosette on tile 8 cannot be ⚔️captured. A piece trying to capture it will simply bounce off onto tile 9.

How to play

Playing Ur on my GitHub profile is easy. The dice have already been rolled for you — all you have to do is decide what to do with them. Anyone with a GitHub account can play.

Anyone can join either team at any time, but once you're in a team, you're locked into it until the game ends. You won't be able to play a move when it's the other team's turn.

The list of links below the board image shows each possible move. Clicking one of those will take you to a page where you can create an issue in this repository, where all you have to do is click submit to play your move.

It will take a moment for Github Actions to acknowledge your move, but once it does, you'll see it react with the 'eyes' emoji (:eyes:). A few seconds later it will react with the 'rocket' emoji (:rocket:) to let you know that your move was successful, then leave a comment explaining what happened, and it'll also make a commit to record your move.

(If you don't see any of that, then something went wrong. Ping me in your issue by typing cc @rossjrw, and I'll take a look.)

Note that if your team has no possible moves — for example by rolling a 0 — your turn will be automatically skipped. The event log will let you know if this has happened.

Behind the scenes

Check out the source branch of this repository for the source code and a little commentary on the inspiration behind this project.

Contributing

I welcome bug reports, feature suggestions and pull requests! Just make sure you ping me in your issue or PR by adding cc @rossjrw, as I don't receive notifications for new issues in this repository (for hopefully obvious reasons).


pr-preview-action's People

Contributors

boneskull avatar cxong avatar dan-hanlon avatar ejfrick avatar electrofelix avatar endbug avatar erikwrede avatar jleifeld avatar kolibril13 avatar mh4gf avatar netomi avatar noatamir avatar okinawaa avatar renestalder avatar rossjrw avatar vorburger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pr-preview-action's Issues

Race condition with build workflow

Just encountered a situation where the build and preview workflow occurred at the same time (during the merge of a PR). They both attempted to write a commit on top of the current gh-pages commit. This resulted in the gh-pages branch moving to the commit that removed the preview for the PR, whereas the commit that deployed the build for the new commit made to the main branch was lost.

I will need to investigate running workflows synchronously.

Rename parameters to be consistent with JamesIves' action

It was a silly idea to make this action so parallel to JamesIves', while also renaming parameters.

E.g. 'source-dir' should be renamed to 'folder'.

This will result in much easier integration with projects using JamesIves/github-pages-deploy-action, which is the intended use case.

I should retain the current parameters, but mark them as deprecated.

Resolve permissions error when preview is initiated from fork

https://github.com/scpwiki/interwiki/runs/5834681840?check_suite_focus=true

This workflow run failed because it did not have permission to push to the upstream repository.

I believe this happened because the workflow was executed from the fork. The pull_request event is executed in the context of the merge commit, whereas the pull_request_target event is executed in the base repository. For internal PRs, these are identical; for forks, they are not. In particular this means that the action will not have permission to push to the repository when using the pull_request event type, as its GITHUB_TOKEN lacks that permission.

Switching to the pull_request_target event might resolve this, but there are security considerations to take into account: https://securitylab.github.com/research/github-actions-preventing-pwn-requests/

Changes shouldn't be needed to this action, but I will need to amend documentation to cover this use case. The README is getting pretty bloated - I should take this chance to move some of the code samples into the repository proper.

Customise comment text

Relates to #25 (comment)

It'd be good to be able to customise the text of the comment left by the action.

I figure it should be possible to let the user pass a string argument which can be used as the message for the marocchino/sticky-pull-request-comment step, with the current message string being the default argument.

The user could be able to use this argument to opt-out of the comment, e.g. it could skip the step if the comment is false or if it's an empty string. That behaviour might even make it possible for the user to change whether or not they want to post a comment based on various conditions. Possible use case: user wants to use their own comment/notification mechanism.

I was initially worried about code injection (https://docs.github.com/en/enterprise-cloud@latest/actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections), given that I'd have to pass a string containing variables to be interpolated, but I don't think this is actually a problem at all because the user will write that string in their workflow file and the variables will be interpolated there.

I'm not clear on how to get env variables into the string that will only be known at runtime, though (e.g. ${{ env.pagesurl }} in the current string. Might Just Work with no changes needed, might need some thought.

Use custom domain for preview

First, thanks for the Awesome Project!

I have a repo that uses a custom URL, but the actions still uses the normal GitHub Pages URL.
It would be great if there is a way to set a custom URL for the action to use, that would also help if someone is using this on another page host.

Investigate Deployment Reviews as a method of informed consent acquisition

As suggested by @aspiers in #6: Deployment Reviews as a potential workaround option for getting previews from forks by blocking the preview behind a manual review step, with information about the risks

  • Native GitHub feature that blocks a specific workflow from running until manually approved
  • Documentation is not 100% clear on whether it's a free feature / if it will work in free private repos
  • Totally unmentioned how to implement/configure the feature - can I pass a message explaining the risks?

`uses:` keyword is not currently supported

I have googled around the error uses: keyword is not currently supported, but couldn't figure out how to fix this issue (other actions are working fine, and they use uses). It's the first time I've seen this, so I thought I'd raise an issue here.

I can see that the Action works nice for public repos:

https://github.com/rossjrw/pr-preview-action/tree/gh-pages/pr-preview/pr-8
#8

I'm trying this in GitHub Enterprise on a self-hosted runner, but it fails with a really weird error.

Action run logs

2023-02-14T18:56:00.7683072Z Found online and idle self-hosted runner(s) in the current repository's organization/enterprise account that matches the required labels: 'self-hosted'
2023-02-14T18:56:00.7683941Z Waiting for a self-hosted runner to pick up this job...
2023-02-14T18:56:10.0154451Z Current runner version: '2.302.0'
2023-02-14T18:56:10.0162322Z Runner name: 'my-runner'
2023-02-14T18:56:10.0162762Z Runner group name: 'Default'
2023-02-14T18:56:10.0163385Z Machine name: 'abc123def'
2023-02-14T18:56:10.0165051Z ##[group]GITHUB_TOKEN Permissions
2023-02-14T18:56:10.0165679Z Actions: write
2023-02-14T18:56:10.0165898Z Checks: write
2023-02-14T18:56:10.0166176Z Contents: write
2023-02-14T18:56:10.0166437Z Deployments: write
2023-02-14T18:56:10.0166676Z Discussions: write
2023-02-14T18:56:10.0166887Z Issues: write
2023-02-14T18:56:10.0167107Z Metadata: read
2023-02-14T18:56:10.0167320Z Packages: write
2023-02-14T18:56:10.0167539Z PullRequests: write
2023-02-14T18:56:10.0167798Z RepositoryProjects: write
2023-02-14T18:56:10.0168015Z SecurityEvents: write
2023-02-14T18:56:10.0168300Z Statuses: write
2023-02-14T18:56:10.0168521Z ##[endgroup]
2023-02-14T18:56:10.0172360Z Prepare workflow directory
2023-02-14T18:56:10.1738386Z Prepare all required actions
2023-02-14T18:56:10.2070688Z Getting action download info
2023-02-14T18:56:16.5313348Z Download action repository 'actions/checkout@v3' (SHA:ac593985615ec2ede58e132d2e21d2b1cbd6127c)
2023-02-14T18:56:16.8288999Z Download action repository 'rossjrw/pr-preview-action@v1' (SHA:eac2838daf487e8f054a4bc10dc957431cd6270b)
2023-02-14T18:56:17.2948704Z ##[error]`uses:` keyword is not currently supported.

Workflow yaml

Indentaiton may be off due to copy paste, but here is the action - pretty much the same as an example from the readme:

name: Deploy PR previews
concurrency: preview-${{ github.ref }}
 
on:
  pull_request:
    types:
    - opened
    - reopened
    - synchronize
    - closed
jobs:
  deploy-preview:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v3
      - run: yarn install && yarn build
      - uses: rossjrw/pr-preview-action@v1

If I remove - uses: rossjrw/pr-preview-action@v1, the logs manage to checkout and then try and install yarn etc.
So, it seems like it gets confused on the very last line.

Support custom 404 previews

Hello, thanks for making this great Action.
I'm trying to test adding a new 404 page and wondered if I'm going about it the wrong way.

The docs for GitHub Pages say that you can have a custom 404 page by putting a 404.html in the root of the deployment.

If I create a 404 page and add it as part of a PR, I can see it by going to https://[owner].github.io/[repo]/pr-preview/pr-[number]/404.html but it does not function as a catch-all, for example when I go to https://[owner].github.io/[repo]/pr-preview/pr-[number]/this/page/does/not/exist I see the default GitHub Pages 404 instead of mine. Would it be possible to get this working?

Fail gracefully when run from fork

Running this action from a fork is not currently supported. Right now, behaviour when running from a fork is undefined; I don't remember exactly what happens, I think it just errors and tells you the action failed. It would be good to have some sort of non-fail (warning?) alert happen instead.

How can I load gh-pages/pr-preview file?

this is my workflows file.

name: Create Preview Site
on:
  pull_request:
    types:
      - opened
      - reopened
      - synchronize

permissions:
  contents: write
  issues: write
  pull-requests: write
  id-token: write
  pages: write
  deployments: write

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

jobs:
  deploy-preview:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      - name: Build
        run: yarn install && yarn build

      - name: Deploy preview
        uses: rossjrw/pr-preview-action@v1
        with:
          source-dir: ./dist/
          preview-branch: gh-pages
          umbrella-dir: pr-preview/
          action: auto

and this is my pr-preview/pr-22/assets/ on gh-pages branch.

image

But I can not access my index-dd097f21.js file on my deployed site for preview.

image

How can I access pr-preview directory on gh-pages branch?

Cleanup is not happening as it should on PR close

We currently have 200+ orphaned directories under our PR previews. The action runs, but nothing is being deleted. Here is the output:


Checking configuration and starting deployment… 🚦
Deploying using Deploy Token… 🔑
Configuring git…
/usr/bin/git config --global --add safe.directory /home/runner/work/vision-web/vision-web
/usr/bin/git config user.name xaviergmail
/usr/bin/git config user.email [email protected]
/usr/bin/git config core.ignorecase false
/usr/bin/git config --local --unset-all http.https://github.com/.extraheader
/usr/bin/git remote rm origin
/usr/bin/git remote add origin ***github.com/<redacted>
Git configured… 🔧
Starting to commit changes…
/usr/bin/git ls-remote --heads ***github.com/<redacted>.git refs/heads/gh-pages
6460bcf9c7b548bce1544e269a8ee0d4e21cc652	refs/heads/gh-pages
Creating worktree…
/usr/bin/git fetch --no-recurse-submodules --depth=1 origin gh-pages
From https://github.com/<redacted>
  * branch            gh-pages   -> FETCH_HEAD
 * [new branch]      gh-pages   -> origin/gh-pages
/usr/bin/git worktree add --no-checkout --detach github-pages-deploy-action-temp-deployment-folder
Preparing worktree (detached HEAD ef1ddab)
/usr/bin/git checkout -B gh-pages origin/gh-pages
Previous HEAD position was ef1ddab Merge 47a6e8a6cdf30c80c317f0b6d0896a4b8be0995f into cb1eea009e14ea6d3f882c373f2094c4f144a4df
Switched to a new branch 'gh-pages'
branch 'gh-pages' set up to track 'origin/gh-pages'.
/usr/bin/chmod -R +rw /tmp/tmp.MoYqQjkDJm
Creating target folder if it doesn't already exist… 📌
/usr/bin/rsync -q -av --checksum --progress /tmp/tmp.MoYqQjkDJm/. github-pages-deploy-action-temp-deployment-folder/pr-previews/pr-1923 --delete --exclude CNAME --exclude .nojekyll --exclude .ssh --exclude .git --exclude .github
Checking if there are files to commit…
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/z4xrvq1b2
Switched to a new branch 'github-pages-deploy-action/z4xrvq1b2'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
There is nothing to commit. Exiting early… 📭

not finding the content

Hello i have to sites with this feature.

One works perfectly after compiling all the files into html.

The other is just a site with static html file, doesnt compile nothing and these are the settings:
name: Deploy PR previews
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
jobs:
deploy-preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy PR Preview
uses: rossjrw/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
preview-branch: gh-pages
source-dir: .
umbrella-dir: pr-preview
action: auto

     *When open the PR it provides a link with my preview but that preview is empty, does anyone knows how to fix it or maybe im putting the wrong source-dir?
     
     Any help is well appreaciated.
     Thanks.

404 page not found

After following the Usage, I'm able to see deploy preview link in the PR. However, when I access the link, I get taken to a 404 page not found.

In the screenshot below, it shows the gh-pages branch which contains my index.html file (ie: pr-preview > pr-90 > index.html). Am I missing a step?

Screen Shot 2022-08-17 at 5 15 39 PM

Below is my config. In the master branch, my index.html lives in docs > index.html

name: Deploy PR previews

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

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

jobs:
  deploy-preview:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup node
        uses: actions/setup-node@v2
        with:
          node-version: 14
          registry-url: 'https://registry.npmjs.org'
        env:
          NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}

      - name: Install and Build
        run: |
          npm install
          npm run build
          npm run build-storybook

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

Branch footer link in posted comment is wrong when a `deploy-repository` is used

E.g. in www-learn-study/saraswati.learn.study#28 the https://www-learn-study.github.io/previews/pr-preview/pr-28/ URL is correct (there was a preview there, it's now removed again), but the https://github.com/www-learn-study/saraswati.learn.study/tree/gh-pages (from on branch gh-pages at 2023-11-02 05:08 UTC) is wrong... that should be https://github.com/www-learn-study/previews/tree/gh-pages - it's not using the deploy-repository there.

Incompatible with GitHub github.io convention

It seems that pr-preview-action is incompatible with the GitHub convention of naming the repository <org/user>.github.io where GitHub serves the pages with the website root at the origin of the site from the repo, rather than adding the repo name as the first path in the URL.

In particular this line

https://github.com/rossjrw/pr-preview-action/blob/main/action.yml#L63

just inserts github.io between the organisation name and the repo name. So I get

Screen Shot 2022-10-21 at 2 38 38 pm

as the preview URL. Everything else works fine, and I can edit the url so it is correct, but clearly in this case the logic is incorrect. I'm half convinced I must be missing something, because this is a long standing convention which I was sure the tool should understand.

I'm guessing some simple logic of checking if the repo name is already ends with <org/user>.github.io might be sufficient, in which case pagesurl should just be the .

How to build on `gh-pages` when push on `main` ?

https://github.com/rossjrw/pr-preview-action is really convenient to get a quick pull request preview!
I'd like to ask: Is it possible to also build the main GitHub pages site on the gh-pages branch, when I push a commit to the main branch?
Currently, I use this action https://github.com/JamesIves/github-pages-deploy-action
But the problem with this approach:
The github-pages-deploy-action overwrites all files on the gh-pages branch, and therefore the files created by pr-preview-action will be overwritten.
Here are the two workflows:
https://github.com/kolibril13/okapi2/tree/main/.github/workflows

fatal git error is not detected (return value ignored?) and check is reported as succesful although it failed

https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6727951896/job/18286524048 from www-learn-study/saraswati.learn.study#42 has an example of a fatal git error what was not detected (return value ignored?) and check is reported as succesful although it failed:

(...)
Checking if there are files to commit…
/usr/bin/git add --all .
/usr/bin/git checkout -b github-pages-deploy-action/ii3mg6sxx
Switched to a new branch 'github-pages-deploy-action/ii3mg6sxx'
/usr/bin/git commit -m Deploy preview for PR 42 🛫 --quiet --no-verify
Pushing changes… (attempt 1 of 3)
/usr/bin/git push --porcelain ***github.com/www-learn-study/previews.git github-pages-deploy-action/ii3mg6sxx:gh-pages
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/www-learn-study/previews.git/'
Changes committed to the gh-pages branch… 📦
Running post deployment cleanup jobs… 🗑️
/usr/bin/git checkout -B github-pages-deploy-action/ii3mg6sxx
Reset branch 'github-pages-deploy-action/ii3mg6sxx'
/usr/bin/chmod -R +rw github-pages-deploy-action-temp-deployment-folder
/usr/bin/git worktree remove github-pages-deploy-action-temp-deployment-folder --force
Completed deployment successfully! ✅
Run echo "url=https://www-learn-study.github.io/previews/pr-preview/pr-42/"  >> $GITHUB_OUTPUT
Run marocchino/sticky-pull-request-comment@v2

Improve Doc about fatal: Authentication failed when using custom `token`

https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6727951896/job/18286524048 from www-learn-study/saraswati.learn.study#42 has an example of a fatal: Authentication failed in an Action using custom token (with a deploy-repository, but unrelated).

I think I have a suspicion what the problem is, and will validate a fix - and likely propose a PR with a minor documentation improvement to clarify how token must be set.

Preview URL in comment doesn't match Enterprise deployment URL

I'm working on a private repo so I hope you not having access to it won't be an issue, but what I'm facing right now is that the comment gives me the following content:

Deployed preview to https://noimosai.github.io/noimos-ui-kit/pr-preview/pr-18/

However this link doesn't work and gives me a 404. I checked the gh-pages branch and the content is there. Apparently it is a new GitHub thing or I configured something wrong but my actual deployment is another URL:

https://friendly-adventure-lnjz19e.pages.github.io/ and I can access the preview content using the adapted URL https://friendly-adventure-lnjz19e.pages.github.io/pr-preview/pr-18/

Here is my config:
image

Did I configure something wrong ?

Customize pr name

Preview URLs look like this: https://[owner].github.io/[repo]/pr-preview/pr-[number]/

Can we customized the path pr-[number]. Doesnt seem like we can

Use links of the deploy preview, not actual deployment

I'm running into an issue where clicking on any link on the landing page on deploy preview take me to the page on actual deployment being served from the root of gh-pages branch instead of the deploy preview generated using pr-review-action.

For example, my index page has a link to "Introduction" which takes me to <user>.github.io/<repo>/docs/introduction. For a deploy preview built using pr-review-action, I expect it to take me to <user>.github.io/<repo>/pr-review/pr-<pr-number>/docs/introduction.

For reference, you can take a look at https://github.com/dharmit/odo-gh-actions/pull/6. The deploy preview is available at https://dharmit.github.io/odo-gh-actions/pr-preview/pr-6/. But when I click on "Read the docs" button, it takes me to https://dharmit.github.io/odo-gh-actions/docs/introduction while I expect it to take me to https://dharmit.github.io/odo-gh-actions/pr-preview/pr-6//docs/introduction.

Help setting up pr-previews

Hey

I am trying to use pr-previews for one of my projects - compressed-sensing/algorithms#11

I want my production website gh-pages branch and preview website preview-{pr-num} branch to be separate as I don't want the original production website to be overwritten whenever I create a pr

I also want multiple prs to have previews available along with the production website running so that we can compare.

Could you help me out? I think its doable with your action but Im struggling to set it up

Error: Resource not accessible by integration

In https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6727753248/job/18286039868 I have run into this:

Run marocchino/sticky-pull-request-comment@v2
  with:
    header: pr-preview
    message: [PR Preview Action](https://github.com/rossjrw/pr-preview-action) v1.4.4
  :---:
  :rocket: Deployed preview to https://www-learn-study.github.io/previews/pr-preview/pr-43/
  on branch [`gh-pages`](https://github.com/www-learn-study/saraswati.learn.study/tree/gh-pages) at 2023-11-02 03:00 UTC 
    append: false
    recreate: false
    delete: false
    only_create: false
    only_update: false
    hide_details: false
    hide: false
    hide_and_recreate: false
    hide_classify: OUTDATED
    ignore_empty: false
    skip_unchanged: false
    follow_symbolic_links: false
    GITHUB_TOKEN: ***
  env:
    action: deploy
    targetdir: pr-preview/pr-43
    pr: 43
    pagesurl: www-learn-study.github.io/previews
    emptydir: /tmp/tmp.NX01XUKSxB
    datetime: [202](https://github.com/www-learn-study/saraswati.learn.study/actions/runs/6727753248/job/18286039868#step:4:208)3-11-02 03:00 UTC
    actionref: v1
    actionrepo: rossjrw/pr-preview-action
    deployrepo: www-learn-study/previews
    token: PREVIEW_TOKEN
    action_version: v1.4.4
    deployment_status: success
Error: Resource not accessible by integration

I've figured out how to fix it (permissions: ...), and will post a PR with a proposed docs clarification.

Combine with `actions/deploy-pages`

This workflow seems to target the "classic" GitHub Pages experience. However, nowadays there's also the newer workflow using https://github.com/marketplace/actions/deploy-github-pages-site

image

I'm trying to combine the two actions but so far I've been unsuccessful: either nothing happens, or I'm getting errors coming from actions/deploy-pages saying Branch "..." is not allowed to deploy to github-pages due to environment protection rules.

Do you have an example on how to use rossjrw/pr-preview-action with the new workflow?

Comment shows target repo version, not action version

We have a lot of different tags in our repo using it in documentation preview title is kind of silly. Please add feature to change or remove it, it would make our PR comment much nicer!

Example of how it looks right now:
image

Error when setting action version via SHA

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.

Don't post preview comment until actual GitHub Pages deployment workflow completed?

Testing this out, and it works great! One thing I noticed is that, understandably, the action only waits for itself to finish to post the comment on the pull request. It would be great if that could somehow be delayed until the actual GitHub Pages deployment process has completed so that the preview link works as soon as it's posted. Right now, there's a short period of time between when the comment is posted and when the link will actually go somewhere.

I'm using this action in a website template that will be used by many non-technical users, and I could see them getting confused by there being a link but the preview not being ready yet.

As for how to implement this, I'm not sure. Is it possible for this Action to somehow add the associated GitHub Pages deployment run as a Status Check to the PR? Maybe it's possible to use action-wait-for-check or some similar action to wait for the deployment to succeed in the middle of running this action (I guess after committing to the gh-pages branch so the build starts, but before returning successfully).

Or maybe a stop gap could simply be adding a message to the pull request comment that clarifies that the preview WILL be available (after a short moment) at the following link.

PR Preview Action v1.2.0
Built preview to branch gh-pages at 2022-11-21 20:33 UTC
🚀 Your preview will be available at https://vincerubinetti.github.io/test/pr-preview/pr-1/
once GitHub finishes deploying it

Customize the directory to serve from

Our Github Pages configuration is set up to serve from a subdirectory and there is currently no documented way to address this with pr-preview-action.

Example:

Preview Deployment Action

      - name: Deploy Preview
        uses: rossjrw/pr-preview-action@v1
        with:
          source-dir: docs
          preview-branch: gh-pages
          umbrella-dir: docs/pr-preview
          action: auto

Deployment Action

      - uses: JamesIves/github-pages-deploy-action@v4
        with:
          folder: docs
          target-folder: docs
          branch: gh-pages
          clean-exclude: docs/pr-preview

With the above configurations, we end up with everything correctly being saved to the docs directory.  The generated preview link is /docs/pr-preview/pr-xx.  I can delete the /docs path part and see the preview just fine, but the generated link shows a totally valid 404 because we are serving directly from the docs directory that things are being saved to rather than serving from the root directory.

Add ability to specify GitHub pages directory

Currently as far as I can tell, you are not able to specify the directory you are using to serve your GitHub pages project.
This means when the preview URL is generated it still includes the pages directory pointing to a broken link.

For example, my repo uses docs/ as the GitHub pages base directory, with the following config I get this output:

          source-dir: 'build'
          preview-branch: 'master'
          umbrella-dir: 'docs/preview'
          custom-url: 'example.site'

Output URL: https://example.site/docs/preview/pr-123
Expected URL: https://example.site/preview/pr-123

Do not create a new comment on removal

A comment should only be created when deploying a new preview. When that preview is removed, that comment should be edited, but it should not be created if it does not already exist.

This hasn't actually happened yet, but it will.

Please allow passing the token

The JamesIves/github-pages-deploy-action and marocchino/sticky-pull-request-comment actions allow using personal access token in addition to the GITHUB_TOKEN. Please allow users of your action to also specify the token to be passed to the called actions.

Can this run in a container? Getting error

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

Check for org pages repo matches unexpectedly

I'm using this action in https://github.com/vagrant-libvirt/vagrant-libvirt, unfortunately because the repo name matches the org name, the current behaviour of identifying repos for updating org gh-pages repos things that previews for the main application which should show up under https://vagrant-libvirt.github.io/vagrant-libvirt/ as though they should appear under https://vagrant-libvirt.github.io/

This can be seen with vagrant-libvirt/vagrant-libvirt#1733 (comment) which indicates the preview should appear as https://vagrant-libvirt.github.io/pr-preview/pr-1733/ when the correct URL is https://vagrant-libvirt.github.io/vagant-libvirt/pr-preview/pr-1733/

It appears this was caused by an improvement to try and generate the correct preview URLs for PRs in repos updating org pages

org=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 1)
thirdleveldomain=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2 | cut -d "." -f 1)
if [ ! -z "$customurl" ]; then
pagesurl="$customurl"
elif [ "$org" == "$thirdleveldomain" ]; then
pagesurl="${org}.github.io"

It appears that the code behaviour is expecting to match the following scenario:

GITHUB_REPOSITORY="vagrant-libvirt/vagrant-libvirt.github.io"

org=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 1)
thirdleveldomain=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2 | cut -d "." -f 1)
[ "$org" == "$thirdleveldomain" ] && echo "${org} == ${thirdleveldomain}"

Unfortunately it will also match on the following:

GITHUB_REPOSITORY="vagrant-libvirt/vagrant-libvirt"

org=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 1)
thirdleveldomain=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2 | cut -d "." -f 1)
[ "$org" == "$thirdleveldomain" ] && echo "${org} == ${thirdleveldomain}"

A simple fix should be to skip removal of the dot domain components:

org=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 1)
thirdleveldomain=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)
[ "${org}.github.io" == "$thirdleveldomain" ] && echo "${org} == ${thirdleveldomain}"

will correctly skip outputting when GITHUB_REPOSITORY="vagrant-libvirt/vagrant-libvirt" while still detecting GITHUB_REPOSITORY="vagrant-libvirt/vagrant-libvirt.github.io"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.