diff --git a/.github/workflows/lychee-version.yml b/.github/workflows/lychee-version.yml new file mode 100644 index 0000000..bc8aa26 --- /dev/null +++ b/.github/workflows/lychee-version.yml @@ -0,0 +1,86 @@ +name: "Update Lychee Default Version" + +on: + schedule: + - cron: "0 0 * * 0" # every Sunday + workflow_dispatch: + repository_dispatch: + +jobs: + check-lychee-version: + runs-on: ubuntu-latest + + outputs: + mismatch: ${{ steps.compare-versions.outputs.mismatch }} + action_lychee_version: ${{ steps.get-action-lychee-version.outputs.result }} + release_version: ${{ steps.get-lychee-release.outputs.release_version }} + + name: Check lychee version + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Get current lychee release version + id: get-lychee-release + run: | + echo "Fetching the latest lychee release version..." + release=$(curl -s https://api.github.com/repos/lycheeverse/lychee/releases/latest | jq -r .tag_name) + release=${release#lychee-} # Strip the 'lychee-' prefix + echo "Latest release version fetched: $release" + echo "release_version=$release" >> $GITHUB_OUTPUT + + - name: Extract lycheeVersion from action.yml + id: get-action-lychee-version + uses: mikefarah/yq@master + with: + cmd: yq '.inputs.lycheeVersion.default' action.yml + + - name: Compare versions + id: compare-versions + run: | + echo "Comparing versions..." + action_lychee_version="${{ steps.get-action-lychee-version.outputs.result }}" + release_version="${{ steps.get-lychee-release.outputs.release_version }}" + echo "Action lychee version: $action_lychee_version" + echo "Latest release version: $release_version" + if [ "$action_lychee_version" != "$release_version" ]; then + echo "Versions do not match. Setting mismatch to true." + echo "mismatch=true" >> $GITHUB_OUTPUT + else + echo "Versions match. Setting mismatch to false." + echo "mismatch=false" >> $GITHUB_OUTPUT + fi + + create-pr: + permissions: + contents: write + pull-requests: write + + needs: check-lychee-version + runs-on: ubuntu-latest + if: needs.check-lychee-version.outputs.mismatch == 'true' + + name: Create PR to update lychee version + env: + action_lychee_version: ${{ needs.check-lychee-version.outputs.action_lychee_version }} + release_version: ${{ needs.check-lychee-version.outputs.release_version }} + update_branch_name: "update-lychee-${{ needs.check-lychee-version.outputs.release_version }}" + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Update lycheeVersion in action.yml + uses: mikefarah/yq@master + with: + cmd: yq -i '.inputs.lycheeVersion.default = "${{ env.release_version }}"' action.yml + + - name: Create Pull Request + uses: peter-evans/create-pull-request@v7 + with: + branch: ${{ env.update_branch_name }} + title: "Update lycheeVersion to ${{ env.release_version }}" + body: "This PR updates the lycheeVersion to the latest release version ${{ env.release_version }} ." + labels: "automated-pr" + assignees: mre + reviewers: Arteiii,thomas-zahner diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f890573..50d1b58 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,3 +1,5 @@ +name: Test lychee-action + on: push: branches: diff --git a/.github/workflows/test_cache.yml b/.github/workflows/test_cache.yml index 4dafa94..2ec4d6d 100644 --- a/.github/workflows/test_cache.yml +++ b/.github/workflows/test_cache.yml @@ -1,8 +1,12 @@ +name: Test cache + on: - - repository_dispatch - - workflow_dispatch - - push - - pull_request + push: + branches: + - master + pull_request: + workflow_dispatch: + repository_dispatch: jobs: lychee-action: diff --git a/action.yml b/action.yml index b706f73..ac95673 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,5 @@ name: "Lychee Broken Link Checker" description: "Quickly check links in Markdown, HTML, and text files" - inputs: args: description: "Lychee arguments (https://github.com/lycheeverse/lychee#commandline-parameters)" @@ -46,12 +45,10 @@ inputs: description: "Directory to run lychee in" default: "." required: false - outputs: exit_code: description: "The exit code returned from Lychee" value: ${{ steps.run-lychee.outputs.exit_code }} - runs: using: "composite" steps: @@ -60,7 +57,6 @@ runs: echo "$HOME/.local/bin" >> "$GITHUB_PATH" mkdir -p "$HOME/.local/bin" shell: bash - - name: Clean up existing lychee files run: | # Remove any existing lychee binaries or archives to prevent conflicts @@ -68,7 +64,6 @@ runs: rm -rf lychee rm -f "${{ steps.lychee-filename.outputs.filename }}" shell: bash - - name: Download and extract lychee id: lychee-setup run: | @@ -99,12 +94,10 @@ runs: env: LYCHEE_VERSION: ${{ inputs.lycheeVersion }} shell: bash - - name: Install lychee run: | install -t "$HOME/.local/bin" -D lychee shell: bash - - name: Clean up installation files run: | # Remove the downloaded archive and any unnecessary files after installation @@ -112,7 +105,6 @@ runs: shopt -s extglob rm -f lychee!(*-bin|*-lib|*.toml) shell: bash - - name: Run Lychee id: run-lychee working-directory: ${{ inputs.workingDirectory }}