Skip to content

Commit 6f793a7

Browse files
authored
Added Update Default Lychee version workflow (#284)
1 parent 1d97d84 commit 6f793a7

File tree

4 files changed

+96
-12
lines changed

4 files changed

+96
-12
lines changed

.github/workflows/lychee-version.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: "Update Lychee Default Version"
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * 0" # every Sunday
6+
workflow_dispatch:
7+
repository_dispatch:
8+
9+
jobs:
10+
check-lychee-version:
11+
runs-on: ubuntu-latest
12+
13+
outputs:
14+
mismatch: ${{ steps.compare-versions.outputs.mismatch }}
15+
action_lychee_version: ${{ steps.get-action-lychee-version.outputs.result }}
16+
release_version: ${{ steps.get-lychee-release.outputs.release_version }}
17+
18+
name: Check lychee version
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: Get current lychee release version
24+
id: get-lychee-release
25+
run: |
26+
echo "Fetching the latest lychee release version..."
27+
release=$(curl -s https://api.github.com/repos/lycheeverse/lychee/releases/latest | jq -r .tag_name)
28+
release=${release#lychee-} # Strip the 'lychee-' prefix
29+
echo "Latest release version fetched: $release"
30+
echo "release_version=$release" >> $GITHUB_OUTPUT
31+
32+
- name: Extract lycheeVersion from action.yml
33+
id: get-action-lychee-version
34+
uses: mikefarah/yq@master
35+
with:
36+
cmd: yq '.inputs.lycheeVersion.default' action.yml
37+
38+
- name: Compare versions
39+
id: compare-versions
40+
run: |
41+
echo "Comparing versions..."
42+
action_lychee_version="${{ steps.get-action-lychee-version.outputs.result }}"
43+
release_version="${{ steps.get-lychee-release.outputs.release_version }}"
44+
echo "Action lychee version: $action_lychee_version"
45+
echo "Latest release version: $release_version"
46+
if [ "$action_lychee_version" != "$release_version" ]; then
47+
echo "Versions do not match. Setting mismatch to true."
48+
echo "mismatch=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "Versions match. Setting mismatch to false."
51+
echo "mismatch=false" >> $GITHUB_OUTPUT
52+
fi
53+
54+
create-pr:
55+
permissions:
56+
contents: write
57+
pull-requests: write
58+
59+
needs: check-lychee-version
60+
runs-on: ubuntu-latest
61+
if: needs.check-lychee-version.outputs.mismatch == 'true'
62+
63+
name: Create PR to update lychee version
64+
env:
65+
action_lychee_version: ${{ needs.check-lychee-version.outputs.action_lychee_version }}
66+
release_version: ${{ needs.check-lychee-version.outputs.release_version }}
67+
update_branch_name: "update-lychee-${{ needs.check-lychee-version.outputs.release_version }}"
68+
69+
steps:
70+
- name: Checkout repository
71+
uses: actions/checkout@v4
72+
73+
- name: Update lycheeVersion in action.yml
74+
uses: mikefarah/yq@master
75+
with:
76+
cmd: yq -i '.inputs.lycheeVersion.default = "${{ env.release_version }}"' action.yml
77+
78+
- name: Create Pull Request
79+
uses: peter-evans/create-pull-request@v7
80+
with:
81+
branch: ${{ env.update_branch_name }}
82+
title: "Update lycheeVersion to ${{ env.release_version }}"
83+
body: "This PR updates the lycheeVersion to the latest release version ${{ env.release_version }} ."
84+
labels: "automated-pr"
85+
assignees: mre
86+
reviewers: Arteiii,thomas-zahner

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
name: Test lychee-action
2+
13
on:
24
push:
35
branches:

.github/workflows/test_cache.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1+
name: Test cache
2+
13
on:
2-
- repository_dispatch
3-
- workflow_dispatch
4-
- push
5-
- pull_request
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
repository_dispatch:
610

711
jobs:
812
lychee-action:

action.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
name: "Lychee Broken Link Checker"
22
description: "Quickly check links in Markdown, HTML, and text files"
3-
43
inputs:
54
args:
65
description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)"
@@ -46,12 +45,10 @@ inputs:
4645
description: "Directory to run lychee in"
4746
default: "."
4847
required: false
49-
5048
outputs:
5149
exit_code:
5250
description: "The exit code returned from Lychee"
5351
value: ${{ steps.run-lychee.outputs.exit_code }}
54-
5552
runs:
5653
using: "composite"
5754
steps:
@@ -60,15 +57,13 @@ runs:
6057
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
6158
mkdir -p "$HOME/.local/bin"
6259
shell: bash
63-
6460
- name: Clean up existing lychee files
6561
run: |
6662
# Remove any existing lychee binaries or archives to prevent conflicts
6763
rm -f "$HOME/.local/bin/lychee"
6864
rm -rf lychee
6965
rm -f "${{ steps.lychee-filename.outputs.filename }}"
7066
shell: bash
71-
7267
- name: Download and extract lychee
7368
id: lychee-setup
7469
run: |
@@ -99,20 +94,17 @@ runs:
9994
env:
10095
LYCHEE_VERSION: ${{ inputs.lycheeVersion }}
10196
shell: bash
102-
10397
- name: Install lychee
10498
run: |
10599
install -t "$HOME/.local/bin" -D lychee
106100
shell: bash
107-
108101
- name: Clean up installation files
109102
run: |
110103
# Remove the downloaded archive and any unnecessary files after installation
111104
rm -f "${{ steps.lychee-setup.outputs.filename }}"
112105
shopt -s extglob
113106
rm -f lychee!(*-bin|*-lib|*.toml)
114107
shell: bash
115-
116108
- name: Run Lychee
117109
id: run-lychee
118110
working-directory: ${{ inputs.workingDirectory }}

0 commit comments

Comments
 (0)