|
| 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 |
0 commit comments