This commit is contained in:
buanet
2021-08-30 21:54:13 +02:00
parent 43cc2774d0
commit cf4fb97696
2 changed files with 64 additions and 53 deletions

View File

@@ -1,5 +1,5 @@
# Github action to build Docker image from dev branch (tag: dev) # Github action to build Docker image from dev branch (tag: dev)
name: Build image from dev name: Build debian based image (dev-node14)
on: on:
workflow_dispatch: workflow_dispatch:
@@ -8,7 +8,7 @@ on:
- dev - dev
jobs: jobs:
bulid_dev: bulid-dev-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout repo (dev) - name: Checkout repo (dev)
@@ -29,21 +29,12 @@ jobs:
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "This is the Buildnumber/Timestamp: $DATI" echo "This is the Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV echo "dati=$DATI" >> $GITHUB_ENV
# startup script
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./debian/scripts/iobroker_startup.sh > ./debian/scripts/iobroker_startup.tmp
mv -f ./debian/scripts/iobroker_startup.tmp ./debian/scripts/iobroker_startup.sh
# amd64 # amd64
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./amd64/scripts/iobroker_startup.sh > ./amd64/scripts/iobroker_startup.tmp sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" ./debian/node14/Dockerfile > ./debian/node14/Dockerfile.tmp
mv -f ./amd64/scripts/iobroker_startup.tmp ./amd64/scripts/iobroker_startup.sh mv -f ./debian/node14/Dockerfile.tmp ./debian/node14/Dockerfile
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" ./amd64/Dockerfile > ./amd64/Dockerfile.tmp
mv -f ./amd64/Dockerfile.tmp ./amd64/Dockerfile
# arm32v7
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./arm32v7/scripts/iobroker_startup.sh > ./arm32v7/scripts/iobroker_startup.tmp
mv -f ./arm32v7/scripts/iobroker_startup.tmp ./arm32v7/scripts/iobroker_startup.sh
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" ./arm32v7/Dockerfile > ./arm32v7/Dockerfile.tmp
mv -f ./arm32v7/Dockerfile.tmp ./arm32v7/Dockerfile
# arm64v8
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${BUILD}/$DATI/" ./arm64v8/scripts/iobroker_startup.sh > ./arm64v8/scripts/iobroker_startup.tmp
mv -f ./arm64v8/scripts/iobroker_startup.tmp ./arm64v8/scripts/iobroker_startup.sh
sed -e "s/\${VERSION}/$VERSION-dev/" -e "s/\${DATI}/$DATI/" ./arm64v8/Dockerfile > ./arm64v8/Dockerfile.tmp
mv -f ./arm64v8/Dockerfile.tmp ./arm64v8/Dockerfile
- name: Set up manifest tool - name: Set up manifest tool
run: | run: |
@@ -70,45 +61,45 @@ jobs:
username: ${{ secrets.PACKAGES_USER }} username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }} password: ${{ secrets.PACKAGES_PASS }}
- name: Build Docker image (amd64) - name: Build Docker image (node14-amd64)
uses: docker/build-push-action@v2.6.1 uses: docker/build-push-action@v2.6.1
with: with:
context: ./amd64 context: ./debian
file: ./amd64/Dockerfile file: ./debian/node14/Dockerfile
push: true push: true
platforms: linux/amd64 platforms: linux/amd64
tags: | tags: |
buanet/iobroker:dev-amd64, buanet/iobroker:dev-node14-amd64,
ghcr.io/buanet/iobroker:dev-amd64 ghcr.io/buanet/iobroker:dev-node14-amd64
- name: Build Docker image (armv32v7) - name: Build Docker image (node14-arm32v7)
uses: docker/build-push-action@v2.6.1 uses: docker/build-push-action@v2.6.1
with: with:
context: ./arm32v7 context: ./debian
file: ./arm32v7/Dockerfile file: ./debian/node14/Dockerfile
push: true push: true
platforms: linux/arm/v7 platforms: linux/arm/v7
tags: | tags: |
buanet/iobroker:dev-arm32v7, buanet/iobroker:dev-node14-arm32v7,
ghcr.io/buanet/iobroker:dev-arm32v7 ghcr.io/buanet/iobroker:dev-node14-arm32v7
- name: Build Docker image (arm64v8) - name: Build Docker image (node14-arm64v8)
uses: docker/build-push-action@v2.6.1 uses: docker/build-push-action@v2.6.1
with: with:
context: ./arm64v8 context: ./debian
file: ./arm64v8/Dockerfile file: ./debian/node14/Dockerfile
push: true push: true
platforms: linux/arm64 platforms: linux/arm64/v8
tags: | tags: |
buanet/iobroker:dev-arm64v8, buanet/iobroker:dev-node14-arm64v8,
ghcr.io/buanet/iobroker:dev-arm64v8 ghcr.io/buanet/iobroker:dev-node14-arm64v8
- name: Create and push manifests - name: Create and push manifests
run: | run: |
sed -e "s/\${VERSION}/dev/g" -e "s/\${DOCKERTAG}/dev/g" ./manifest.yml > manifest_dev.yaml sed -e "s/\${VERSION}/dev-node14/g" -e "s/\${DOCKERTAG}/dev-node14/g" ./manifest.yml > manifest_dev-node14.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_dev.yaml ./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_dev-node14.yaml
sed -e "s/\${VERSION}/dev/g" -e "s/\${DOCKERTAG}/dev/g" ./manifest_ghcr.yml > manifest_ghcr_dev.yaml sed -e "s/\${VERSION}/dev-node14/g" -e "s/\${DOCKERTAG}/dev-node14/g" ./manifest_ghcr.yml > manifest_ghcr_dev-node14.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_dev.yaml ./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_dev-node14.yaml
- name: Delete untagged images from GitHub packages - name: Delete untagged images from GitHub packages
uses: actions/github-script@v3 uses: actions/github-script@v3

View File

@@ -5,6 +5,7 @@
############################ ############################
autoconfirm=no # yould be set to true by commandline option autoconfirm=no # yould be set to true by commandline option
switch=none
#################################### ####################################
@@ -14,8 +15,9 @@ autoconfirm=no # yould be set to true by commandline option
# display help text # display help text
display_help() { display_help() {
echo "This script is build to manage your ioBroker container!" echo "This script is build to manage your ioBroker container!"
echo "Usage: maintenance [ COMMAND ] [ OPTIONS ]" echo ''
echo " maint [ COMMAND ] [ OPTIONS ]" echo "Usage: maintenance [ COMMAND ] [ OPTION ]"
echo " maint [ COMMAND ] [ OPTION ]"
echo '' echo ''
echo "COMMANDS" echo "COMMANDS"
echo "------------------" echo "------------------"
@@ -23,11 +25,12 @@ display_help() {
echo " on > switches mantenance mode ON" echo " on > switches mantenance mode ON"
echo " off > switches mantenance mode OFF and shuts down/ restarts container" echo " off > switches mantenance mode OFF and shuts down/ restarts container"
echo " upgrade > will put container to maintenance mode and upgrade iobroker" echo " upgrade > will put container to maintenance mode and upgrade iobroker"
echo " help > shows this help"
echo '' echo ''
echo "OPTIONS" echo "OPTIONS"
echo "------------------" echo "------------------"
echo " -h|--help > shows this help"
echo " -y|--yes > confirms the used command without asking" echo " -y|--yes > confirms the used command without asking"
echo " -h|--help > shows this help"
echo '' echo ''
exit 0 exit 0
} }
@@ -129,37 +132,54 @@ upgrade() {
fi fi
} }
############################## ########################################
##### parsing parameters ##### ##### parsing commands and options #####
############################## ########################################
while :; do # reading all arguments and putting them in reverse
case $1 in reverse=
-h|--help) for i in "$@"; do
reverse="$i $reverse"
done
# checking the arguments
for i in $reverse; do
case $i in
help|-h|--help)
display_help # calling function to display help text display_help # calling function to display help text
exit exit
;; ;;
-y|--yes)
autoconfirm=yes # answers prompts with "yes"
;;
status) status)
check_status # calling function to check maintenance mode status check_status # calling function to check maintenance mode status
;; ;;
on|-on) on)
switch_on # calling function to switch maintenance mode on switch_on # calling function to switch maintenance mode on
exit ;;
off)
switch_off # calling function to switch maintenance mode off
;;
upgrade)
upgrade # calling function to upgrade js-controller
;;
-y|--yes)
autoconfirm=yes # setting autoconfrm option to "yes"
;;
-a=*|--argument=*) # dummy exaple for parsing option with value
ARGUMENT="${i#*=}"
shift
;; ;;
--) # End of all options. --) # End of all options.
shift shift
break break
;; ;;
-?*) -?*|?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" echo 'WARN: Unknown parameter. Please try again or see help (-h|--help).'
break
;; ;;
*) # Default case: No more options, so break out of the loop. *) # Default case: No more options, so break out of the loop.
break break
;;
esac esac
shift
done done
exit 0 exit 0