update jenkins plugins #1027
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: update jenkins plugins | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 22 * * *" | |
jobs: | |
build: | |
name: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repo | |
uses: actions/checkout@v2 | |
- name: setup | |
id: setup | |
run: | | |
cp plugins.yaml plugins.current.yaml | |
JENKINS_VERSION=$(grep FROM Dockerfile | cut -d ':' -f2) | |
echo "::set-output name=jenkins-version::$JENKINS_VERSION" | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: check for plugin updates | |
uses: addnab/docker-run-action@v3 | |
with: | |
image: jenkins/jenkins:${{ steps.setup.outputs.jenkins-version }} | |
options: -u root -v ${{ github.workspace }}:/src | |
shell: bash | |
run: | | |
jenkins-plugin-cli --available-updates --plugin-file /src/plugins.current.yaml --output yaml > /src/plugins.yaml | |
jenkins-plugin-cli --available-updates --plugin-file /src/plugins.current.yaml > /src/available-plugin-updates.txt | |
- name: show updated plugins.yaml | |
run: cat plugins.yaml | |
- name: get git diff | |
id: git-diff | |
run: echo "::set-output name=plugins::$(git --no-pager diff --name-only | grep plugins.yaml)" | |
- name: Login to GitHub Container Repository | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
if: steps.git-diff.outputs.plugins | |
- name: set PR body output | |
id: plugin-updates | |
run: | | |
# github actions doesn't support multiline strings so we have to escape them | |
plugins=$(< available-plugin-updates.txt) | |
plugins="${plugins//$'\n'/'%0A'}" | |
echo "::set-output name=plugins::$plugins" | |
if: steps.git-diff.outputs.plugins | |
- name: create pull request | |
uses: peter-evans/create-pull-request@v3 | |
with: | |
branch: latest/plugins | |
commit-message: automated plugin updates | |
add-paths: | | |
plugins.yaml | |
committer: base2bot <noreply@base2services.com> | |
delete-branch: true | |
title: Jenkins plugin updates | |
body: | | |
${{ steps.plugin-updates.outputs.plugins }} | |
labels: | | |
latest-plugins | |
jenkins-distribution | |
if: steps.git-diff.outputs.plugins | |
- name: Build Container Image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
tags: ghcr.io/base2services/jenkins-distribution:latest_plugins | |
push: true | |
if: steps.git-diff.outputs.plugins |