doppler dockerfile added + workflow

This commit is contained in:
MXPicture 2022-02-10 14:13:50 +01:00
parent 58a1579832
commit c1b6b91404
13 changed files with 251 additions and 524 deletions

98
.github/workflows/check_changes.yml vendored Normal file
View file

@ -0,0 +1,98 @@
name: Check Changes
on:
schedule:
# 07:00 UTC each day
- cron: '0 7 * * *'
release:
types: [published]
workflow_dispatch:
jobs:
get_releases:
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.get.outputs.result }}
empty_releases: ${{ steps.check.outputs.result }}
steps:
- name: Docker target releases
id: fetch_target_releases
uses: mxpicture/action-docker-hub-fetch-releases@v1
with:
repository: mxpicture/openwrt-rootfs
max_items: "999999"
- name: Docker source releases
id: fetch_source_releases
uses: mxpicture/action-docker-hub-fetch-releases@v1
with:
repository: openwrtorg/rootfs
max_items: "999999"
- name: Get releases, compare docker hub image dates
uses: actions/github-script@v5
id: get
with:
script: |
const releases = (await github.request("https://api.github.com/repos/"
+ context.repo.owner + "/" + context.repo.repo + "/releases")).data
const target_releases = ${{ steps.fetch_target_releases.outputs.results }}
const source_releases = ${{ steps.fetch_source_releases.outputs.results }}
let output = []
for (const release of releases) {
console.log("Processing release: " + release.tag_name)
for (const source_release of source_releases) {
if ( source_release.tag_name === release.tag_name ) {
let found = false
for (const target_release of target_releases) {
if ( source_release.tag_name === target_release.tag_name ) {
found = true
console.log("Last updated (source): " + source_release.last_updated)
console.log("Last updated (target): " + target_release.last_updated)
if ( source_release.last_updated > target_release.last_updated ) {
console.log("Trigger event for release: " + release.tag_name)
output.push({ "name": release.tag_name })
}
}
}
if (found != true) {
console.log("Trigger event for release: " + release.tag_name)
output.push({ "name": release.tag_name })
}
}
}
}
return output
- name: Check releases empty
uses: actions/github-script@v5
id: check
with:
script: |
let output = ${{ steps.get.outputs.result }}
console.log("Count releases: " + (output.length))
if (output.length == 0) {
console.log("empty")
return 'true'
} else {
console.log("not empty")
return 'false'
}
dispatch:
needs: get_releases
if: ${{ fromJSON(needs.get_releases.outputs.empty_releases) == 'false' }}
runs-on: ubuntu-latest
strategy:
matrix:
release: ${{ fromJSON(needs.get_releases.outputs.releases) }}
steps:
- name: Dispatch deploy
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ github.repository }}
event-type: docker_hub
client-payload: '{"release": "${{ matrix.release.tag_name }}"}'

43
.github/workflows/docker_hub.yml vendored Normal file
View file

@ -0,0 +1,43 @@
name: Docker Hub Deploy
on:
repository_dispatch:
types: [docker_hub]
workflow_dispatch:
jobs:
docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: mxpicture
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract release name
shell: bash
run: echo "##[set-output name=release;]$(echo ${GITHUB_REF#refs/*/})"
if: github.event_name != 'repository_dispatch'
id: extract_release
- name: Build and push (on push)
id: docker_build_push
uses: docker/build-push-action@v2
if: github.event_name != 'repository_dispatch'
with:
push: true
releases: mxpicture/netbox:${{ steps.extract_release.outputs.release }}
build-args: "BASE_IMAGE_VERSION=${{ steps.extract_release.outputs.release }}"
- name: Build and push (on dispatch)
id: docker_build_dispatch
uses: docker/build-push-action@v2
if: github.event_name == 'repository_dispatch'
with:
push: true
releases: mxpicture/netbox:${{ github.event.client_payload.release }}
build-args: "BASE_IMAGE_VERSION=${{ github.event.client_payload.release }}"

View file

@ -0,0 +1,56 @@
name: Force deploy all
on:
workflow_dispatch:
jobs:
get_releases:
runs-on: ubuntu-latest
outputs:
releases: ${{ steps.get.outputs.result }}
empty_releases: ${{ steps.check.outputs.result }}
steps:
- name: Get releases
uses: actions/github-script@v5
id: get
with:
script: |
const releases = (await github.request("https://api.github.com/repos/"
+ context.repo.owner + "/" + context.repo.repo + "/releases")).data
let output = []
for(let i=0; i<releases.length; i++) {
output.push({ "name": releases[i].tag_name })
}
return output
- name: Check releases empty
uses: actions/github-script@v5
id: check
with:
script: |
let output = ${{ steps.get.outputs.result }}
console.log("Count releases: " + (output.length))
if (output.length == 0) {
console.log("empty")
return 'true'
} else {
console.log("not empty")
return 'false'
}
dispatch:
needs: get_releases
if: ${{ fromJSON(needs.get_releases.outputs.empty_releases) == 'false' }}
runs-on: ubuntu-latest
strategy:
matrix:
release: ${{ fromJSON(needs.get_releases.outputs.releases) }}
steps:
- name: Dispatch deploy
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.ACCESS_TOKEN }}
repository: ${{ github.repository }}
event-type: docker_hub
client-payload: '{"release": "${{ matrix.release.name }}"}'

View file

@ -1,66 +0,0 @@
name: push
on:
push:
branches-ignore:
- release
pull_request:
branches-ignore:
- release
jobs:
lint:
runs-on: ubuntu-latest
name: Checks syntax of our code
steps:
- uses: actions/checkout@v2
with:
# Full git history is needed to get a proper list of changed files within `super-linter`
fetch-depth: 0
- uses: actions/setup-python@v2
- name: Lint Code Base
uses: github/super-linter@v4
env:
DEFAULT_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SUPPRESS_POSSUM: true
LINTER_RULES_PATH: /
VALIDATE_ALL_CODEBASE: false
VALIDATE_DOCKERFILE: false
FILTER_REGEX_EXCLUDE: (.*/)?(LICENSE|configuration/.*)
EDITORCONFIG_FILE_NAME: .ecrc
DOCKERFILE_HADOLINT_FILE_NAME: .hadolint.yaml
MARKDOWN_CONFIG_FILE: .markdown-lint.yml
PYTHON_BLACK_CONFIG_FILE: pyproject.toml
PYTHON_FLAKE8_CONFIG_FILE: .flake8
PYTHON_ISORT_CONFIG_FILE: pyproject.toml
build:
continue-on-error: ${{ matrix.docker_from == 'alpine:edge' }}
strategy:
matrix:
build_cmd:
- ./build-latest.sh
- PRERELEASE=true ./build-latest.sh
- ./build.sh feature
- ./build.sh develop
docker_from:
- '' # use the default of the build script
- alpine:edge
fail-fast: false
runs-on: ubuntu-latest
name: Builds new NetBox Docker Images
steps:
- id: git-checkout
name: Checkout
uses: actions/checkout@v2
- id: docker-build
name: Build the image from '${{ matrix.docker_from }}' with '${{ matrix.build_cmd }}'
run: ${{ matrix.build_cmd }}
env:
DOCKER_FROM: ${{ matrix.docker_from }}
GH_ACTION: enable
- id: docker-test
name: Test the image
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
if: steps.docker-build.outputs.skipped != 'true'

View file

@ -1,87 +0,0 @@
name: release
on:
release:
types:
- published
schedule:
- cron: '45 5 * * *'
jobs:
build:
strategy:
matrix:
build_cmd:
- ./build-latest.sh
- PRERELEASE=true ./build-latest.sh
- ./build.sh feature
- ./build.sh develop
fail-fast: false
runs-on: ubuntu-latest
name: Builds new NetBox Docker Images
env:
GH_ACTION: enable
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Get Version of NetBox Docker
run: |
echo "::set-output name=version::$(cat VERSION)"
shell: bash
-
id: docker-build
name: Build the image with '${{ matrix.build_cmd }}'
run: ${{ matrix.build_cmd }}
-
name: Test the image
run: IMAGE="${FINAL_DOCKER_TAG}" ./test.sh
if: steps.docker-build.outputs.skipped != 'true'
# docker.io
-
name: Login to docker.io
uses: docker/login-action@v1
with:
registry: docker.io
username: ${{ secrets.dockerhub_username }}
password: ${{ secrets.dockerhub_password }}
if: steps.docker-build.outputs.skipped != 'true'
-
name: Push the image to docker.io
run: ${{ matrix.build_cmd }} --push-only
if: steps.docker-build.outputs.skipped != 'true'
# quay.io
-
name: Login to Quay.io
uses: docker/login-action@v1
with:
registry: quay.io
username: ${{ secrets.quayio_username }}
password: ${{ secrets.quayio_password }}
if: steps.docker-build.outputs.skipped != 'true'
-
name: Build and push the image with '${{ matrix.build_cmd }}'
run: ${{ matrix.build_cmd }} --push
env:
DOCKER_REGISTRY: quay.io
if: steps.docker-build.outputs.skipped != 'true'
# ghcr.io
-
name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
if: steps.docker-build.outputs.skipped != 'true'
-
name: Build and push the image with '${{ matrix.build_cmd }}'
run: ${{ matrix.build_cmd }} --push
env:
DOCKER_REGISTRY: ghcr.io
DOCKER_ORG: netbox-community
if: steps.docker-build.outputs.skipped != 'true'