Proposal: Support localhost as URL
Closed this issue · 2 comments
Is your feature request related to a problem? Please describe
I use Hugo as open-source static site generator for my website. I would like to check the links of the generated HTML files before publishing my website anywhere. Hugo has a command to start a local web server at localhost:1313. However, I don't know how to provide the local web server to action-my-broken-link-checker
.
I have tried:
- name: Start Web Server
run: |
hugo server &
while ! nc -z localhost 1313 ; do sleep 1s ; done
- name: Check Links
uses: ruzickap/action-my-broken-link-checker@v2
with:
url: http://localhost:1313/v2/
Error:
*** INFO: [2022-09-11 09:34:50] Start checking: "http://localhost:1313/v2/"
*** ERROR: [2022-09-11 09:34:50] Something went wrong - see the errors above...
failed to fetch root page: dial tcp4 12[7](https://github.com/pmwmedia/tinylog-website/runs/8291244346?check_suite_focus=true#step:10:8).0.0.1:1313: connect: connection refused
I have also tried:
- name: Check Links
uses: ruzickap/action-my-broken-link-checker@v2
with:
url: https://tinylog.org/v2/
pages_path: ./public/
Error:
*** INFO: Using path "./public/" as domain "tinylog.org" with URI "https://tinylog.org/"
*** INFO: [2022-09-11 10:04:48] Start checking: "https://tinylog.org/v2/"
failed to fetch root page: 404
{"level":"info","ts":166289068[7](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:8).[8](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:9)01[9](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:10)361,"msg":"using provided configuration","config_file":"/tmp/Caddyfile.AleHgB","config_adapter":""}
{"level":"warn","ts":1662890687.80263[11](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:12),"msg":"Caddyfile input is not formatted; run the 'caddy fmt' command to fix inconsistencies","adapter":"caddyfile","file":"/tmp/Caddyfile.AleHgB","line":2}
{"level":"info","ts":1662890687.8031988,"logger":"admin","msg":"admin endpoint started","address":"tcp/localhost:2019","enforce_origin":false,"origins":["//[12](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:13)7.0.0.1:2019","//localhost:2019","//[::1]:2019"]}
{"level":"info","ts":1662890687.8042064,"logger":"http","msg":"server is listening only on the HTTPS port but has no TLS connection policies; adding one to enable TLS","server_name":"srv0","https_port":443}
{"level":"info","ts":1662890687.8042216,"logger":"http","msg":"enabling automatic HTTP->HTTPS redirects","server_name":"srv0"}
{"level":"info","ts":1662890687.8044977,"logger":"http","msg":"enabling automatic TLS certificate management","domains":["tinylog.org"]}
{"level":"info","ts":1662890687.8068898,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0xc00063f730"}
{"level":"info","ts":1662890687.8072672,"logger":"tls.obtain","msg":"acquiring lock","identifier":"tinylog.org"}
{"level":"info","ts":1662890687.8124647,"logger":"tls.obtain","msg":"lock acquired","identifier":"tinylog.org"}
{"level":"info","ts":1662890687.8144195,"logger":"tls.obtain","msg":"certificate obtained successfully","identifier":"tinylog.org"}
{"level":"info","ts":1662890687.8144295,"logger":"tls.obtain","msg":"releasing lock","identifier":"tinylog.org"}
{"level":"warn","ts":1662890687.8146987,"logger":"tls","msg":"stapling OCSP","error":"no OCSP stapling for [tinylog.org]: no OCSP server specified in certificate","identifiers":["tinylog.org"]}
{"level":"warn","ts":1662890687.8197901,"logger":"pki.ca.local","msg":"installing root certificate (you might be prompted for password)","path":"storage:pki/authorities/local/root.crt"}
{"level":"info","ts":1662890687.8199[13](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:14)4,"msg":"Warning: \"certutil\" is not available, install \"certutil\" with \"apt install libnss3-tools\" or \"yum install nss-tools\" and try again"}
{"level":"info","ts":[16](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:17)62890687.8[19](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:20)9[20](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:21)8,"msg":"define JAVA_HOME environment variable to use the Java trust"}
{"level":"info","ts":1662890687.8548355,"msg":"certificate installed properly in linux trusts"}
{"level":"info","ts":1662890687.855012,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/github/home/.local/share/caddy"}
{"level":"info","ts":1662890687.8550277,"msg":"autosaved config (load with --resume flag)","file":"/github/home/.config/caddy/autosave.json"}
{"level":"info","ts":1662890687.8550408,"msg":"serving initial configuration"}
{"level":"info","ts":1662890687.8552792,"logger":"tls","msg":"finished cleaning storage units"}
Successfully started Caddy (pid=[23](https://github.com/pmwmedia/tinylog-website/runs/8291423464?check_suite_focus=true#step:9:24)) - Caddy is running in the background
sed: can't move '/etc/hostskhdlKE' to '/etc/hosts': Resource busy
I assume that the root page cannot be fetched because "./public/" should be mapped to "https://tinylog.org/v2/" instead of "https://tinylog.org/". The last output sed: can't move '/etc/hostskhdlKE' to '/etc/hosts': Resource busy
looks also a bit odd.
Describe the solution you'd like
My favorite solution would be providing a shell command for starting the web server and action-my-broken-link-checker
would wait until the web server will be up (no need for while ! nc -z localhost 1313 ; do sleep 1s ; done
) and then runs muffet
Example:
- name: Check Links
uses: ruzickap/action-my-broken-link-checker@v2
with:
command: hugo server
url: http://localhost:1313/v2/
Describe alternatives you've considered
An alternative would be passing a folder instead of an URL to action-my-broken-link-checker
and the action starts a web server for static HTML files by itself.
Workaround
- name: Check Links
run: |
hugo server &
while ! nc -z localhost 1313 ; do sleep 1s ; done
wget -q https://github.com/raviqqe/muffet/releases/download/v2.6.1/muffet_2.6.1_Linux_x86_64.tar.gz
tar -zxvf muffet_2.6.1_Linux_x86_64.tar.gz muffet
chmod +x muffet
./muffet http://localhost:1313/v2/
Hello.
I understand the your requirement, but this is not how my-broken-link-checker works.
But I believe you can still use it to check links in your "Hugo site".
Let's take this example hugo-build.yml:
-
First pipeline generates the HTML pages in some directory (it can be Hugo or anything else)
- In my case - I'm using
public
directory - which is the default for Hugo
- In my case - I'm using
-
Then I'm using
ruzickap/action-my-broken-link-checker@v2
to start web server and let link checker to verify all the links.
In this example you do not need to run your webserver using Hugo (or anything else) -> you just need to generate your HTML files and let them tested by my-broken-link-checker
.
Check the example above - maybe it may help you...
See you
PetrR
Thank you, I made it finally working.
I had to change two things to make my second example above working:
- name: Check Links
uses: ruzickap/action-my-broken-link-checker@v2
with:
url: https://tinylog.org/v2/
pages_path: ./public/
-
Downgrade from Ubuntu 22.04 to 20.04 (the action does not work on Ubuntu 22.04)
-
Put my files into
public/v2
instead ofpublic
as the action does not mappublic
to the passed URLhttps://tinylog.org/v2/
. Instead, the action mapspublic
tohttps://tinylog.org/
.