Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Controllo automatico dei link rotti #24

Open
wants to merge 127 commits into
base: master
Choose a base branch
from

Conversation

saver999
Copy link

Il mio script utilizza GitHub Actions per eseguire il controllo dei link rotti nel file README.md. Il workflow scansiona (ogniqualvolta si esegue un push sul branch master ed ogni primo del mese a mezzanotte) tutti i link nel file e verifica se sono raggiungibili. Se un link non è raggiungibile, il workflow apre un'issue nel repository principale per segnalare il link rotto. #20

saver999 and others added 30 commits October 13, 2023 21:23
Ho aggiunto un nuovo workflow di GitHub Actions chiamato 'Check README Links' per verificare i link nel file README.md del progetto.
… progetto. Se trova link rotti, apre automaticamente una nuova issue nel repository segnalando i dettagli del link rotto. L'issue include il link rotto nel titolo e nel corpo.
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
…tti' into Controllo_automatico_dei_link_rotti
Copy link
Member

@bfabio bfabio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @saver999, thank you for the PR! 🚀

.github/workflows/ISSUE_TEMPLATE.md Outdated Show resolved Hide resolved
.github/workflows/ISSUE_TEMPLATE.md Outdated Show resolved Hide resolved
- name: Get links from README.md
id: get-links
run: |
LINKS=$(grep -oP '\[.*?\]\((http[s]?://[^)]*)\)' README.md | sed -E 's/\[.*\]\(([^)]+)\)/\1/' | paste -sd "," -)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LINKS=$(grep -oP '\[.*?\]\((http[s]?://[^)]*)\)' README.md | sed -E 's/\[.*\]\(([^)]+)\)/\1/' | paste -sd "," -)
LINKS=$(grep -oP '\[.*?\]\((http[s]?://[^)]*)\)' README.md | sed -E 's/\[.*\]\(([^)]+)\)/\1/' | paste -sd ,)

Can't we use just sed here?


# Scansiona i link e verifica se sono raggiungibili
for link in "${LINKS[@]}"; do
if [[ $link =~ ^(http|https):// ]]; then
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this guaranteed by the regexps populating $LINKS?

.github/workflows/controllo_link.yml Outdated Show resolved Hide resolved
.github/workflows/controllo_link.yml Outdated Show resolved Hide resolved
.github/workflows/controllo_link.yml Outdated Show resolved Hide resolved
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: ${{ env.ISSUE_TEMPLATE }}
if: failure()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will run when the link checker job is successful, in case actions/checkout fails.

- uses: actions/checkout@v3
if: failure()

- uses: JasonEtco/create-an-issue@v2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this action create a new issue everytime? Because if thats the case, we want to create a new issue if there's no issue opened yet, but update the issue if there is already one.

Comment on lines +55 to +56
- uses: actions/checkout@v3
if: failure()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do this because we need a single file (.github/workflows/ISSUE_TEMPLATE.md) and doing so we get the whole history and the rest of the repo. Not a big deal, but maybe we can optimize that, also considering it interferes with the if: failure() logic (see below).

saver999 and others added 5 commits October 16, 2023 21:18
Co-authored-by: Fabio Bonelli <fbonelli@gmail.com>
Co-authored-by: Fabio Bonelli <fbonelli@gmail.com>
…tti' into Controllo_automatico_dei_link_rotti

# Conflicts:
#	.github/workflows/ISSUE_TEMPLATE.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants