File tree Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Expand file tree Collapse file tree 3 files changed +72
-1
lines changed Original file line number Diff line number Diff line change
1
+ name : build-container-image
2
+ on :
3
+ pull_request :
4
+ types :
5
+ - opened
6
+ - edited
7
+ - synchronize
8
+ - reopened
9
+ jobs :
10
+ build :
11
+ name : Build
12
+ runs-on : ubuntu-latest
13
+ steps :
14
+ - name : Checkout GIT repository
15
+ uses : actions/checkout@v3
16
+ - name : Get the application version
17
+ id : application-version
18
+ run : |
19
+ image_version=$(grep "^LABEL site.local.program.version=" Dockerfile | cut -d= -f2 | sed -e 's/"//g')
20
+ if [ -z "${image_version}" ]; then
21
+ echo "ERROR: unable to detect version number!" >&2
22
+ exit 1
23
+ fi
24
+ echo "tag=${image_version}" >> $GITHUB_OUTPUT
25
+ - name : Build container image
26
+ run : |
27
+ docker build . --file Dockerfile --tag oitc/modbus-server:${{steps.application-version.outputs.tag}}
28
+ - name : Export container image for caching
29
+ run : |
30
+ docker save --output oitc-modbus-server_${{steps.application-version.outputs.tag}}.tar oitc/modbus-server:${{steps.application-version.outputs.tag}}
31
+
32
+ - name : Upload the container image for caching
33
+ uses : actions/upload-artifact@v3.1.2
34
+ with :
35
+ name : modbus-server
36
+ path : oitc-modbus-server_${{steps.application-version.outputs.tag}}.tar
37
+ if-no-files-found : error
38
+ retention-days : 1
Original file line number Diff line number Diff line change 3
3
pull_request :
4
4
push :
5
5
branches :
6
- - master
7
6
- main
8
7
jobs :
9
8
pre-commit :
Original file line number Diff line number Diff line change
1
+ name : build-container-image
2
+ on :
3
+ pull_request :
4
+ types :
5
+ - closed
6
+ jobs :
7
+ build :
8
+ name : Push Container Image
9
+ runs-on : ubuntu-latest
10
+ steps :
11
+ - name : Download container image from cache
12
+ uses : actions/download-artifact@v3.0.2
13
+ with :
14
+ name : modbus-server
15
+ - name : Identify container version
16
+ id : vars
17
+ run : |
18
+ container_image_file=$(find . -name "oitc-modbus-server_*.tar" -type -f | tail -1)
19
+ if [ -z "${container_image_file}" ]; then
20
+ echo "ERROR: Unable to get the container image file!" >&2
21
+ exit 1
22
+ fi
23
+ container_version=$(basename ${container_image_file} | cut -d_ -f2 | sed -e 's/\.tar$//')
24
+ image_name="oitc/modbus-server:${container_version}"
25
+
26
+ echo "container_image_file=${container_image_file}" >> $GITHUB_OUTPUT
27
+ echo "container_version=${container_version}" >> $GITHUB_OUTPUT
28
+ echo "image_name=${image_name}" >> $GITHUB_OUTPUT
29
+ - name : Import container image
30
+ run : docker import ${{steps.vars.outputs.container_image_file}}
31
+ - name : Login to container registry
32
+ run : echo ${{ secrets.DOCKERHUB_PASSWORD }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
33
+ - name : Upload container image to container registry
34
+ run : docker push ${{steps.vars.outputs.image_name}}
You can’t perform that action at this time.
0 commit comments