Skip to content

Ignore host-network pods when calculating max pods per node. #160

Ignore host-network pods when calculating max pods per node.

Ignore host-network pods when calculating max pods per node. #160

# DO NOT EDIT. Generated with:
#
# devctl@5.9.0
#
name: Create Release PR
on:
push:
branches:
- 'legacy#release#v*.*.*'
- 'main#release#v*.*.*'
- 'main#release#major'
- 'main#release#minor'
- 'main#release#patch'
- 'master#release#v*.*.*'
- 'master#release#major'
- 'master#release#minor'
- 'master#release#patch'
- 'release#v*.*.*'
- 'release#major'
- 'release#minor'
- 'release#patch'
- 'release-v*.*.x#release#v*.*.*'
# "!" negates previous positive patterns so it has to be at the end.
- '!release-v*.x.x#release#v*.*.*'
workflow_call:
inputs:
branch:
required: true
type: string
jobs:
debug_info:
name: Debug info
runs-on: ubuntu-20.04
steps:
- name: Print github context JSON
run: |
cat <<EOF
${{ toJson(github) }}
EOF
gather_facts:
name: Gather facts
runs-on: ubuntu-20.04
outputs:
repo_name: ${{ steps.gather_facts.outputs.repo_name }}
branch: ${{ steps.gather_facts.outputs.branch }}
base: ${{ steps.gather_facts.outputs.base }}
is_major: ${{ steps.gather_facts.outputs.is_major }}
skip: ${{ steps.pr_exists.outputs.skip }}
version: ${{ steps.gather_facts.outputs.version }}
steps:
- name: Gather facts
id: gather_facts
run: |
head="${{ inputs.branch || github.event.ref }}"
echo "::set-output name=branch::${head}"
head="${head#refs/heads/}" # Strip "refs/heads/" prefix.
if [[ $(echo "$head" | grep -o '#' | wc -l) -gt 1 ]]; then
base="$(echo $head | cut -d '#' -f 1)"
else
base="${{ github.event.base_ref }}"
fi
base="${base#refs/heads/}" # Strip "refs/heads/" prefix.
version="$(echo $head | awk -F# '{print $NF}')"
if [[ $version =~ ^major|minor|patch$ ]]; then
gh auth login --with-token <<<$(echo -n ${{ secrets.GITHUB_TOKEN }})
version_parts=($(gh api "repos/${{ github.repository }}/releases/latest" --jq '.tag_name[1:] | split(".") | .[0], .[1], .[2]'))
version_major=${version_parts[0]}
version_minor=${version_parts[1]}
version_patch=${version_parts[2]}
case ${version} in
patch)
version_patch=$((version_patch+1))
;;
minor)
version_minor=$((version_minor+1))
version_patch=0
;;
major)
version_major=$((version_major+1))
version_minor=0
version_patch=0
echo "::set-output name=is_major::true"
;;
*)
echo "Unknown Semver level provided"
exit 1
;;
esac
version="${version_major}.${version_minor}.${version_patch}"
else
version="${version#v}" # Strip "v" prefix.
version_major=$(echo "${version}" | cut -d "." -f 1)
version_minor=$(echo "${version}" | cut -d "." -f 2)
version_patch=$(echo "${version}" | cut -d "." -f 3)
if [[ $version_minor = 0 && $version_patch = 0 ]]; then
echo "::set-output name=is_major::true"
fi
fi
repo_name="$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')"
echo "repo_name=\"$repo_name\" base=\"$base\" head=\"$head\" version=\"$version\""
echo "::set-output name=repo_name::${repo_name}"
echo "::set-output name=base::${base}"
echo "::set-output name=head::${head}"
echo "::set-output name=version::${version}"
- name: Check if PR exists
id: pr_exists
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
run: |
if gh pr view --repo ${{ github.repository }} ${{ steps.gather_facts.outputs.branch }} | grep -i 'state:[[:space:]]*open' >/dev/null; then
gh pr view --repo ${{ github.repository }} ${{ steps.gather_facts.outputs.branch }}
echo "::set-output name=skip::true"
else
echo "::set-output name=skip::false"
fi
create_release_pr:
name: Create release PR
runs-on: ubuntu-20.04
needs:
- gather_facts
if: ${{ needs.gather_facts.outputs.skip != 'true' }}
env:
architect_flags: "--organisation ${{ github.repository_owner }} --project ${{ needs.gather_facts.outputs.repo_name }}"
steps:
- uses: actions/setup-go@v3
with:
go-version: '=1.18.1'
- name: Install architect
uses: giantswarm/install-binary-action@v1.0.0
with:
binary: "architect"
version: "6.1.0"
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ needs.gather_facts.outputs.branch }}
- name: Prepare release changes
run: |
architect prepare-release ${{ env.architect_flags }} --version "${{ needs.gather_facts.outputs.version }}"
- name: Update version field in Chart.yaml
run: |
# Define chart_dir
repository="${{ needs.gather_facts.outputs.repo_name }}"
chart="helm/${repository}"
# Check chart directory.
if [ ! -d "${chart}" ]
then
echo "Could not find chart directory '${chart}', adding app suffix."
# Add app suffix.
chart="helm/${repository}-app"
# Check chart directory with app suffix.
if [ ! -d "${chart}" ]
then
echo "Could not find chart directory '${chart}', removing app suffix."
# Remove app suffix.
chart="helm/${repository%-app}"
if [ ! -d "${chart}" ]
then
# Print error.
echo "Could not find chart directory '${chart}', doing nothing."
fi
fi
fi
# Define chart YAML.
chart_yaml="${chart}/Chart.yaml"
# Check chart YAML.
if [ -f "${chart_yaml}" ]
then
# check if version in Chart.yaml is templated using architect
if [ $(grep -c "^version:.*\.Version.*$" "${chart_yaml}") = "0" ]; then
yq -i '.version = "${{ needs.gather_facts.outputs.version }}"' "${chart_yaml}"
fi
fi
- name: Bump go module defined in go.mod if needed
run: |
if [ "${{ needs.gather_facts.outputs.is_major }}" = true ] && test -f "go.mod"; then
go install github.com/marwan-at-work/mod/cmd/mod@v0.4.2
mod upgrade
fi
- name: Set up git identity
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: Create release commit
env:
version: "${{ needs.gather_facts.outputs.version }}"
run: |
git add -A
git commit -m "Release v${{ env.version }}"
- name: Push changes
env:
remote_repo: "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git"
run: |
git push "${remote_repo}" HEAD:${{ needs.gather_facts.outputs.branch }}
- name: Create PR
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
base: "${{ needs.gather_facts.outputs.base }}"
version: "${{ needs.gather_facts.outputs.version }}"
run: |
hub pull-request -f -m "Release v${{ env.version }}" -a ${{ github.actor }} -b ${{ env.base }} -h ${{ needs.gather_facts.outputs.branch }}