Skip to content

Update plugins

Update plugins #13294

---
name: Update plugins
on:
schedule:
- cron: "*/15 * * * *"
workflow_dispatch:
jobs:
main:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 17
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2.1.0
id: generate-token
with:
app_id: ${{ secrets.JENKINS_ADMIN_APP_ID }}
private_key: ${{ secrets.JENKINS_ADMIN_APP_PRIVKEY }}
- id: update-plugins
name: Update plugins
run: |
set +x
# Use a temp file to avoid commits by error
temp_dir="$(mktemp -d)"
orig_plugins_file="${temp_dir}"/original-plugins.txt
diff_file="${temp_dir}"/diff.txt
# Keep a copy of the original plugins file
cp ./plugins.txt "${orig_plugins_file}"
# Update it
./bin/update-plugins.sh ./plugins.txt
# Store comparison between original and updated
diff --unified=0 "${orig_plugins_file}" ./plugins.txt > "${diff_file}" || true
if [ -s "${diff_file}" ]; then
pluginsdiff="$(tail --lines +3 "${diff_file}" | grep -v '@')"
newlines=$(echo "${pluginsdiff}" | grep '+')
links=''
while read -r line
do
pluginName=${line%:*}
pluginVersion=${line#*:}
links+="[${pluginName//+}:${pluginVersion}](https://plugins.jenkins.io/${pluginName//+}/releases/#version_${pluginVersion})<br>"
done <<< "$newlines"
delimiter="$(openssl rand -hex 8)"
# shellcheck disable=SC2129
echo "pluginsdiff<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "${pluginsdiff}" >> "$GITHUB_OUTPUT"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
delimiter="$(openssl rand -hex 8)"
echo "links<<${delimiter}" >> "${GITHUB_OUTPUT}"
echo "${links}" >> "$GITHUB_OUTPUT"
echo "${delimiter}" >> "${GITHUB_OUTPUT}"
echo "changed=true" >> "${GITHUB_OUTPUT}"
else
echo "changed=false" >> "${GITHUB_OUTPUT}"
fi
- name: Create Pull Request
if: ${{ steps.update-plugins.outputs.changed == 'true' }}
id: create-pull-request
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # v7.0.5
with:
commit-message: 'chore(deps): update infra.ci.jenkins.io plugins'
signoff: false
title: 'chore(deps): update infra.ci.jenkins.io plugins'
author: jenkins-infra-updatecli[bot] <178728+jenkins-infra-updatecli[bot]@users.noreply.github.com>
committer: jenkins-infra-updatecli[bot] <178728+jenkins-infra-updatecli[bot]@users.noreply.github.com>
branch: update-infra-ci-plugins
token: ${{ steps.generate-token.outputs.token }}
labels: dependencies,infra-ci-plugins
body: |
### Change(s):
```diff
${{ steps.update-plugins.outputs.pluginsdiff }}
```
### Link(s):
${{ steps.update-plugins.outputs.links }}