Skip to content

Remove unused code, update controller-tools #281

Remove unused code, update controller-tools

Remove unused code, update controller-tools #281

Workflow file for this run

name: main
on:
push:
pull_request:
release:
types: [created]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.21
id: go
- uses: azure/setup-helm@v1
with:
version: 'v3.9.0'
id: helm
- name: Check out code into the Go module directory
uses: actions/checkout@v1
- name: Get dependencies
run: go get -v -t -d ./...
- name: Lint, unit test and build
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make vendor_modules
# Run code generation
make generate
# Lint and format the codebase
make lint
make format
# Check diff for changes in committed code and generated/linted code
git diff --exit-code
make test
if [ ${{ github.event_name }} == "release" ]; then
# github.ref is in the form refs/tags/VERSION, so apply regex to just get version
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
else
VERSION=$(git rev-parse --short ${{ github.sha }})
fi
make docker VERSION=${VERSION}
- name: Deploy
env:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
if: github.event_name != 'pull_request' && github.repository == 'jthomperoo/custom-pod-autoscaler-operator'
run: |
if [ ${{ github.event_name }} == "release" ]; then
# github.ref is in the form refs/tags/VERSION, so apply regex to just get version
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
else
VERSION=$(git rev-parse --short ${{ github.sha }})
fi
echo "$DOCKER_PASS" | docker login --username=$DOCKER_USER --password-stdin
docker push custompodautoscaler/operator:${VERSION}
if [ ${{ github.event_name }} == "release" ]; then
docker tag custompodautoscaler/operator:${VERSION} custompodautoscaler/operator:latest
docker push custompodautoscaler/operator:latest
fi
- name: Bundle YAML config
if: github.event_name == 'release' && github.repository == 'jthomperoo/custom-pod-autoscaler-operator'
run: |
# Variables to sub into k8s templates
if [ ${{ github.event_name }} == "release" ]; then
# github.ref is in the form refs/tags/VERSION, so apply regex to just get version
VERSION=$(echo "${{ github.ref }}" | grep -P '([^\/]+$)' -o)
else
VERSION=$(git rev-parse --short ${{ github.sha }})
fi
export VERSION=${VERSION}
sed -i "/version: 0.0.0/c\version: ${VERSION}" helm/Chart.yaml
helm package helm/
helm template helm/ --set mode=cluster > cluster.yaml
helm template helm/ --set mode=namespaced > namespaced.yaml
- name: Deploy helm package
if: github.event_name == 'release' && github.repository == 'jthomperoo/custom-pod-autoscaler-operator'
uses: Shopify/[email protected]
with:
name: custom-pod-autoscaler-operator-${{ github.event.release.tag_name }}.tgz
path: custom-pod-autoscaler-operator-${{ github.event.release.tag_name }}.tgz
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy cluster-scope YAML config
if: github.event_name == 'release' && github.repository == 'jthomperoo/custom-pod-autoscaler-operator'
uses: Shopify/[email protected]
with:
name: cluster.yaml
path: cluster.yaml
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Deploy namespace-scope YAML config
if: github.event_name == 'release' && github.repository == 'jthomperoo/custom-pod-autoscaler-operator'
uses: Shopify/[email protected]
with:
name: namespaced.yaml
path: namespaced.yaml
repo-token: ${{ secrets.GITHUB_TOKEN }}