File tree Expand file tree Collapse file tree 4 files changed +62
-0
lines changed
actions/update_pipeline_lib_branch Expand file tree Collapse file tree 4 files changed +62
-0
lines changed Original file line number Diff line number Diff line change
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" ]
Original file line number Diff line number Diff line change
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'
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 }}
You can’t perform that action at this time.
0 commit comments