diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 4932ae8..d803cbc 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -15,7 +15,8 @@ build_cmd: - ./build-latest.sh - PRERELEASE=true ./build-latest.sh - - ./build-branches.sh + - ./build-next.sh + - ./build.sh develop docker_from: - '' # use the default of the DOCKERFILE - python:3.7-alpine diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1796097..9dbf770 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,14 +14,15 @@ build_cmd: - ./build-latest.sh - PRERELEASE=true ./build-latest.sh - - ./build-branches.sh + - ./build-next.sh + - ./build.sh develop fail-fast: false runs-on: ubuntu-latest name: Builds new Netbox Docker Images steps: - id: git-checkout name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - id: docker-build name: Build the image with '${{ matrix.build_cmd }}' run: ${{ matrix.build_cmd }} diff --git a/build-branches.sh b/build-branches.sh deleted file mode 100755 index 483e771..0000000 --- a/build-branches.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# Builds develop, develop-* and master branches of Netbox - -echo "▶️ $0 $*" - -### -# Checking for the presence of GITHUB_OAUTH_CLIENT_ID -# and GITHUB_OAUTH_CLIENT_SECRET -### -if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then - echo "🗝 Performing authenticated Github API calls." - GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}" -else - echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!" - GITHUB_OAUTH_PARAMS="" -fi - -### -# Calling Github to get the all branches -### -ORIGINAL_GITHUB_REPO="${SRC_ORG-netbox-community}/${SRC_REPO-netbox}" -GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}" -URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches?${GITHUB_OAUTH_PARAMS}" - -# Composing the JQ commans to extract the most recent version number -JQ_BRANCHES='map(.name) | .[] | scan("^[^v].+") | match("^(master|develop).*") | .string' - -CURL="curl -sS" - -# Querying the Github API to fetch all branches -BRANCHES=$($CURL "${URL_RELEASES}" | jq -r "$JQ_BRANCHES") - -### -# Building each branch -### - -# keeping track whether an error occured -ERROR=0 - -# calling build.sh for each branch -for BRANCH in $BRANCHES; do - # shellcheck disable=SC2068 - ./build.sh "${BRANCH}" $@ || ERROR=1 -done - -# returning whether an error occured -exit $ERROR diff --git a/build-next.sh b/build-next.sh new file mode 100755 index 0000000..c833d52 --- /dev/null +++ b/build-next.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Builds develop, develop-* and master branches of Netbox + +echo "▶️ $0 $*" + +### +# Checking for the presence of GITHUB_OAUTH_CLIENT_ID +# and GITHUB_OAUTH_CLIENT_SECRET +### +if [ -n "${GITHUB_OAUTH_CLIENT_ID}" ] && [ -n "${GITHUB_OAUTH_CLIENT_SECRET}" ]; then + echo "🗝 Performing authenticated Github API calls." + GITHUB_OAUTH_PARAMS="client_id=${GITHUB_OAUTH_CLIENT_ID}&client_secret=${GITHUB_OAUTH_CLIENT_SECRET}" +else + echo "🕶 Performing unauthenticated Github API calls. This might result in lower Github rate limits!" + GITHUB_OAUTH_PARAMS="" +fi + +### +# Calling Github to get the all branches +### +ORIGINAL_GITHUB_REPO="${SRC_ORG-netbox-community}/${SRC_REPO-netbox}" +GITHUB_REPO="${GITHUB_REPO-$ORIGINAL_GITHUB_REPO}" +URL_RELEASES="https://api.github.com/repos/${GITHUB_REPO}/branches?${GITHUB_OAUTH_PARAMS}" + +# Composing the JQ commans to extract the most recent version number +JQ_NEXT='map(.name) | .[] | scan("^[^v].+") | match("^(develop-).*") | .string' + +CURL="curl -sS" + +# Querying the Github API to fetch all branches +NEXT=$($CURL "${URL_RELEASES}" | jq -r "$JQ_NEXT") + +# shellcheck disable=SC2068 +./build.sh "${NEXT}" $@