Skip to content

Commit

Permalink
add github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
buanet committed Aug 4, 2021
1 parent 0aba419 commit e7ddf2f
Show file tree
Hide file tree
Showing 4 changed files with 399 additions and 0 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/docker_build_beta_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# Github action to build Docker image from beta branch (tag: beta)

name: Build Docker image from beta

on:
pull_request:
branches:
- beta
types:
- closed

jobs:
bulid_beta:
runs-on: ubuntu-latest
steps:
- name: Checkout (beta)
uses: actions/[email protected]
with:
repository: 'buanet/ioBroker.docker'
ref: 'beta'

- name: Get and write version and date
id: version
run: |
VERSION="$(cat .VERSION)"
MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')"
DATI="$(date --rfc-3339=seconds | sed 's/ /T/')"
echo "This is the Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "This is the Major Version: $MAJORVERSION"
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "This is the Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./amd64/Dockerfile > ./amd64/Dockerfile.tmp
mv -f ./amd64/Dockerfile.tmp ./amd64/Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./arm32v7/Dockerfile > ./arm32v7/Dockerfile.tmp
mv -f ./arm32v7/Dockerfile.tmp ./arm32v7/Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./arm64v8/Dockerfile > ./arm64v8/Dockerfile.tmp
mv -f ./arm64v8/Dockerfile.tmp ./arm64v8/Dockerfile
- name: Set up manifest tool
run: |
wget https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 -O manifest-tool
chmod +x manifest-tool
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }}

- name: Build Docker image (amd64)
uses: docker/[email protected]
with:
context: ./amd64
file: ./amd64/Dockerfile
push: true
platforms: linux/amd64
tags: |
buanet/iobroker:${{ env.version }}-amd64,
ghcr.io/buanet/iobroker:${{ env.version }}-amd64
- name: Build Docker image (armv32v7)
uses: docker/[email protected]
with:
context: ./arm32v7
file: ./arm32v7/Dockerfile
push: true
platforms: linux/arm/v7
tags: |
buanet/iobroker:${{ env.version }}-arm32v7,
ghcr.io/buanet/iobroker:${{ env.version }}-arm32v7
- name: Build Docker image (arm64v8)
uses: docker/[email protected]
with:
context: ./arm64v8
file: ./arm64v8/Dockerfile
push: true
platforms: linux/arm64
tags: |
buanet/iobroker:${{ env.version }}-arm64v8,
ghcr.io/buanet/iobroker:${{ env.version }}-arm64v8
- name: Create and push manifests
run: |
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/beta/g" ./manifest.yml > manifest_beta.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_beta.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/beta/g" ./manifest_ghcr.yml > manifest_ghcr_beta.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_beta.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.version }}/g" ./manifest.yml > manifest_version.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_version.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.version }}/g" ./manifest_ghcr.yml > manifest_ghcr_version.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_version.yaml
- name: Delete untagged images from GitHub packages
uses: actions/github-script@v3
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |
const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}
env:
OWNER: buanet
PACKAGE_NAME: iobroker
PER_PAGE: 100
122 changes: 122 additions & 0 deletions .github/workflows/docker_build_dev_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
# Github action to build Docker image from dev branch (tag: testing)

name: Build Docker image from dev

on:
push:
branches:
- dev

jobs:
bulid_dev:
runs-on: ubuntu-latest
steps:
- name: Checkout repo (dev)
uses: actions/[email protected]
with:
repository: 'buanet/ioBroker.docker'
ref: 'dev'

- name: Get and write version and date
id: version
run: |
VERSION="$(cat .VERSION)"
MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')"
DATI="$(date --rfc-3339=seconds | sed 's/ /T/')"
echo "This is the Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "This is the Major Version: $MAJORVERSION"
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "This is the Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV
sed -e "s/\${VERSION}/$VERSION-devbuild/" -e "s/\${DATI}/$DATI/" ./amd64/Dockerfile > ./amd64/Dockerfile.tmp
mv -f ./amd64/Dockerfile.tmp ./amd64/Dockerfile
sed -e "s/\${VERSION}/$VERSION-devbuild/" -e "s/\${DATI}/$DATI/" ./arm32v7/Dockerfile > ./arm32v7/Dockerfile.tmp
mv -f ./arm32v7/Dockerfile.tmp ./arm32v7/Dockerfile
sed -e "s/\${VERSION}/$VERSION-devbuild/" -e "s/\${DATI}/$DATI/" ./arm64v8/Dockerfile > ./arm64v8/Dockerfile.tmp
mv -f ./arm64v8/Dockerfile.tmp ./arm64v8/Dockerfile
- name: Set up manifest tool
run: |
wget https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 -O manifest-tool
chmod +x manifest-tool
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }}

- name: Build Docker image (amd64)
uses: docker/[email protected]
with:
context: ./amd64
file: ./amd64/Dockerfile
push: true
platforms: linux/amd64
tags: |
buanet/iobroker:dev-amd64,
ghcr.io/buanet/iobroker:dev-amd64
- name: Build Docker image (armv32v7)
uses: docker/[email protected]
with:
context: ./arm32v7
file: ./arm32v7/Dockerfile
push: true
platforms: linux/arm/v7
tags: |
buanet/iobroker:dev-arm32v7,
ghcr.io/buanet/iobroker:dev-arm32v7
- name: Build Docker image (arm64v8)
uses: docker/[email protected]
with:
context: ./arm64v8
file: ./arm64v8/Dockerfile
push: true
platforms: linux/arm64
tags: |
buanet/iobroker:dev-arm64v8,
ghcr.io/buanet/iobroker:dev-arm64v8
- name: Create and push manifests
run: |
sed -e "s/\${VERSION}/dev/g" -e "s/\${DOCKERTAG}/dev/g" ./manifest.yml > manifest_dev.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_dev.yaml
sed -e "s/\${VERSION}/dev/g" -e "s/\${DOCKERTAG}/dev/g" ./manifest_ghcr.yml > manifest_ghcr_dev.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_dev.yaml
- name: Delete untagged images from GitHub packages
uses: actions/github-script@v3
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |
const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}
env:
OWNER: buanet
PACKAGE_NAME: iobroker
PER_PAGE: 100
130 changes: 130 additions & 0 deletions .github/workflows/docker_build_main_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Github action to build Docker image from main branch (tag: latest)

name: Build Docker image from main

on:
release:
types:
- published

jobs:
bulid_latest:
runs-on: ubuntu-latest
steps:
- name: Checkout (main)
uses: actions/[email protected]
with:
repository: 'buanet/ioBroker.docker'
ref: 'main'

- name: Get and wirte version and date
id: version
run: |
VERSION="$(cat .VERSION)"
MAJORVERSION="$(cat .VERSION | cut -c 1-2 | sed -r 's#^(.{0})#\1latest-#')"
DATI="$(date --rfc-3339=seconds | sed 's/ /T/')"
echo "This is the Version: $VERSION"
echo "version=$VERSION" >> $GITHUB_ENV
echo "This is the Major Version: $MAJORVERSION"
echo "majorversion=$MAJORVERSION" >> $GITHUB_ENV
echo "This is the Buildnumber/Timestamp: $DATI"
echo "dati=$DATI" >> $GITHUB_ENV
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./amd64/Dockerfile > ./amd64/Dockerfile.tmp
mv -f ./amd64/Dockerfile.tmp ./amd64/Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./arm32v7/Dockerfile > ./arm32v7/Dockerfile.tmp
mv -f ./arm32v7/Dockerfile.tmp ./arm32v7/Dockerfile
sed -e "s/\${VERSION}/$VERSION/" -e "s/\${DATI}/$DATI/" ./arm64v8/Dockerfile > ./arm64v8/Dockerfile.tmp
mv -f ./arm64v8/Dockerfile.tmp ./arm64v8/Dockerfile
- name: Set up manifest tool
run: |
wget https://github.com/estesp/manifest-tool/releases/download/v0.7.0/manifest-tool-linux-amd64 -O manifest-tool
chmod +x manifest-tool
- name: Set up QEMU
uses: docker/[email protected]

- name: Set up Docker Buildx
id: buildx
uses: docker/[email protected]

- name: Login to DockerHub
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}

- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ secrets.PACKAGES_USER }}
password: ${{ secrets.PACKAGES_PASS }}

- name: Build Docker image (amd64)
uses: docker/[email protected]
with:
context: ./amd64
file: ./amd64/Dockerfile
push: true
platforms: linux/amd64
tags: |
buanet/iobroker:${{ env.version }}-amd64,
ghcr.io/buanet/iobroker:${{ env.version }}-amd64
- name: Build Docker image (armv32v7)
uses: docker/[email protected]
with:
context: ./arm32v7
file: ./arm32v7/Dockerfile
push: true
platforms: linux/arm/v7
tags: |
buanet/iobroker:${{ env.version }}-arm32v7,
ghcr.io/buanet/iobroker:${{ env.version }}-arm32v7
- name: Build Docker image (arm64v8)
uses: docker/[email protected]
with:
context: ./arm64v8
file: ./arm64v8/Dockerfile
push: true
platforms: linux/arm64
tags: |
buanet/iobroker:${{ env.version }}-arm64v8,
ghcr.io/buanet/iobroker:${{ env.version }}-arm64v8
- name: Create and push manifests
run: |
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/latest/g" ./manifest.yml > manifest_latest.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_latest.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.majorversion }}/g" ./manifest.yml > manifest_latestmajor.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_latestmajor.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.version }}/g" ./manifest.yml > manifest_version.yaml
./manifest-tool --username ${{ secrets.DOCKER_USER }} --password ${{ secrets.DOCKER_PASS }} push from-spec manifest_version.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/latest/g" ./manifest_ghcr.yml > manifest_ghcr_latest.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_latest.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.majorversion }}/g" ./manifest_ghcr.yml > manifest_ghcr_latestmajor.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_latestmajor.yaml
sed -e "s/\${VERSION}/${{ env.version }}/g" -e "s/\${DOCKERTAG}/${{ env.version }}/g" ./manifest_ghcr.yml > manifest_ghcr_version.yaml
./manifest-tool --username ${{ secrets.PACKAGES_USER }} --password ${{ secrets.PACKAGES_PASS }} push from-spec manifest_ghcr_version.yaml
- name: Delete untagged images from GitHub packages
uses: actions/github-script@v3
with:
github-token: ${{ secrets.PACKAGES_PASS }}
script: |
const response = await github.request("GET /users/${{ env.OWNER }}/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
}
}
env:
OWNER: buanet
PACKAGE_NAME: iobroker
PER_PAGE: 100
Loading

0 comments on commit e7ddf2f

Please sign in to comment.