Improve workflows #24
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| paths-ignore: | |
| - '.gitignore' | |
| - 'CODEOWNERS' | |
| - 'LICENSE' | |
| - '*.md' | |
| - '*.adoc' | |
| - '*.txt' | |
| pull_request: | |
| paths-ignore: | |
| - '.gitignore' | |
| - 'CODEOWNERS' | |
| - 'LICENSE' | |
| - '*.md' | |
| - '*.adoc' | |
| - '*.txt' | |
| env: | |
| IMG_REGISTRY: ghcr.io/slyngdk/ | |
| IMG_NAME_CONTROLLER: nodedrain-controller | |
| IMG_NAME_EXAM_PLUGIN: nodedrain-example-plugin | |
| jobs: | |
| container-build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Login to GitHub Container Registry | |
| if: github.ref_protected | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Build image | |
| id: build_image | |
| run: | | |
| export IMG_TAG=ci-${{ github.ref_name }} | |
| if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" == "main" ]]; then | |
| export IMG_TAG=latest | |
| elif [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| export IMG_TAG=$(echo -n "${{ github.ref_name }}" | sed 's/^v//g') | |
| fi | |
| export IMG_TAG=${IMG_TAG//\//-} | |
| echo "IMG_TAG=${IMG_TAG}" >> $GITHUB_OUTPUT | |
| make docker-build | |
| - name: Push image | |
| if: github.ref_protected | |
| env: | |
| IMG_TAG: ${{ steps.build_image.outputs.IMG_TAG }} | |
| run: | | |
| if [[ "${{ github.ref_type }}" == "branch" && "${{ github.ref_name }}" != "main" ]] || [[ "${{ github.ref_type }}" == "tag" && ! "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Only push main branch and versioned tags" | |
| exit 1 | |
| fi | |
| make docker-push | |
| helm-package: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| - name: Install Helm | |
| run: | | |
| curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash | |
| - name: Verify Helm installation | |
| run: helm version | |
| - name: Login to GitHub Container Registry | |
| if: github.ref_protected | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Helm package | |
| run: | | |
| export VERSION=999 | |
| if [[ "${{ github.ref_type }}" == "tag" && "${{ github.ref_name }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| export VERSION=$(echo -n "${{ github.ref_name }}" | sed 's/^v//g') | |
| fi | |
| helm package dist/chart -u --version ${VERSION} --app-version ${VERSION} | |
| if [[ "${VERSION}" != "999" ]]; then | |
| helm push "nodedrain-${VERSION}.tgz" "oci://ghcr.io/slyngdk/charts" | |
| fi |