Skip to content

Commit 4a1713f

Browse files
committed
Add pipeline-lib branch update action
Signed-off-by: Brian J. Murrell <brian.murrell@intel.com>
1 parent 1682ac6 commit 4a1713f

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM alpine:3.10
2+
3+
COPY entrypoint.sh /entrypoint.sh
4+
5+
RUN apk add --no-cache bash
6+
7+
ENTRYPOINT ["/entrypoint.sh"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name: 'Update Pipeline Library Branch'
2+
description: 'Update the pipeline-lib Library reference to be the current branch'
3+
author: 'Brian J. Murrell'
4+
runs:
5+
using: 'docker'
6+
image: 'Dockerfile'
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash -l
2+
3+
set -eux
4+
5+
my_branch=${GITHUB_REF#refs/heads/}
6+
my_branch_RE=${my_branch//\//\\/}
7+
8+
if [ $my_branch = master ]; then
9+
# landing, return to standard commented out hint
10+
sed -i -e "/^@Library(value=\"pipeline-lib@/s/\(.*-lib@\).*\(\".*\)$/\/\/ \1my_pr_branch\2/" Jenkinsfile
11+
exit 0
12+
fi
13+
14+
if grep "^@Library(value=\"pipeline-lib@${my_branch_RE}\") _" Jenkinsfile; then
15+
# already set, nothing to do
16+
exit 0
17+
fi
18+
19+
if grep "^@Library(value=\"pipeline-lib@" Jenkinsfile; then
20+
# set to something else set, change it
21+
sed -i -e "/^@Library(value=\"pipeline-lib@/s/\(lib@\).*\"/\1${my_branch_RE}\"/" Jenkinsfile
22+
exit 0
23+
fi
24+
25+
# not set at all, add it
26+
sed -i -e "s/^\/\/ \(@Library(value=\"pipeline-lib@\)my_pr_branch\(\") _\)/\1${my_branch_RE}\2/" Jenkinsfile
27+
28+
exit 0
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Set Pipeline Library Branch
2+
# This workflow is triggered on pushes to the master branch of the repository.
3+
on:
4+
push:
5+
6+
jobs:
7+
update_pipeline_lib_branch:
8+
name: Update Pipeline Library Branch
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
with:
13+
ref: ${{ github.head_ref }}
14+
- uses: ./.github/actions/update_pipeline_lib_branch
15+
- uses: stefanzweifel/git-auto-commit-action@v4
16+
with:
17+
commit_message: Update pipeline-lib branch
18+
commit_options: '--signoff'
19+
id: update_pipeline_lib_branch
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)