diff --git a/.github/actions/kubebuilder/Dockerfile b/.github/actions/kubebuilder/Dockerfile new file mode 100644 index 0000000..2ebd633 --- /dev/null +++ b/.github/actions/kubebuilder/Dockerfile @@ -0,0 +1,6 @@ +FROM giantswarm/tiny-tools + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/kubebuilder/action.yml b/.github/actions/kubebuilder/action.yml new file mode 100644 index 0000000..b582dbb --- /dev/null +++ b/.github/actions/kubebuilder/action.yml @@ -0,0 +1,9 @@ +name: 'kubebuilder' +description: 'A GitHub Action to run kubebuilder commands' +author: 'Stefan Prodan' +branding: + icon: 'command' + color: 'blue' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/.github/actions/kubebuilder/entrypoint.sh b/.github/actions/kubebuilder/entrypoint.sh new file mode 100644 index 0000000..f7f2dad --- /dev/null +++ b/.github/actions/kubebuilder/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh -l + +VERSION=2.3.1 + +curl -sL https://go.kubebuilder.io/dl/${VERSION}/linux/amd64 | tar -xz -C /tmp/ + +mkdir -p $GITHUB_WORKSPACE/kubebuilder +mv /tmp/kubebuilder_${VERSION}_linux_amd64/* $GITHUB_WORKSPACE/kubebuilder/ +ls -lh $GITHUB_WORKSPACE/kubebuilder/bin + +echo "::add-path::$GITHUB_WORKSPACE/kubebuilder/bin" +echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/kubebuilder/bin" diff --git a/.github/actions/kustomize/Dockerfile b/.github/actions/kustomize/Dockerfile new file mode 100644 index 0000000..2ebd633 --- /dev/null +++ b/.github/actions/kustomize/Dockerfile @@ -0,0 +1,6 @@ +FROM giantswarm/tiny-tools + +COPY entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/kustomize/action.yml b/.github/actions/kustomize/action.yml new file mode 100644 index 0000000..bd53d1d --- /dev/null +++ b/.github/actions/kustomize/action.yml @@ -0,0 +1,9 @@ +name: 'kustomize' +description: 'A GitHub Action to run kustomize commands' +author: 'Stefan Prodan' +branding: + icon: 'command' + color: 'blue' +runs: + using: 'docker' + image: 'Dockerfile' diff --git a/.github/actions/kustomize/entrypoint.sh b/.github/actions/kustomize/entrypoint.sh new file mode 100644 index 0000000..9ca798a --- /dev/null +++ b/.github/actions/kustomize/entrypoint.sh @@ -0,0 +1,12 @@ +#!/bin/sh -l + +VERSION=3.1.0 +curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v${VERSION}/kustomize_${VERSION}_linux_amd64 + +mkdir -p $GITHUB_WORKSPACE/bin +cp ./kustomize $GITHUB_WORKSPACE/bin +chmod +x $GITHUB_WORKSPACE/bin/kustomize +ls -lh $GITHUB_WORKSPACE/bin + +echo "::add-path::$GITHUB_WORKSPACE/bin" +echo "::add-path::$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" diff --git a/.github/workflows/e2e.yaml b/.github/workflows/e2e.yaml new file mode 100644 index 0000000..3cc3a3f --- /dev/null +++ b/.github/workflows/e2e.yaml @@ -0,0 +1,61 @@ +name: e2e + +on: + pull_request: + push: + branches: + - master + +jobs: + kind: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Restore Go cache + uses: actions/cache@v1 + with: + path: ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + - name: Setup Go + uses: actions/setup-go@v2-beta + with: + go-version: 1.14.x + - name: Setup Kubernetes + uses: engineerd/setup-kind@v0.3.0 + - name: Setup Kustomize + uses: ./.github/actions/kustomize + - name: Setup Kubebuilder + uses: ./.github/actions/kubebuilder + - name: Run tests + run: make test + env: + KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin + - name: Check if working tree is dirty + run: | + if [[ $(git diff --stat) != '' ]]; then + echo 'run make test and commit changes' + exit 1 + fi + - name: Build container image + run: make docker-build IMG=test/notification-controller:latest + env: + KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin + - name: Load test image + run: kind load docker-image test/notification-controller:latest + - name: Deploy controller + run: | + make dev-deploy IMG=test/notification-controller:latest + kubectl -n notification-system rollout status deploy/notification-controller --timeout=1m + env: + KUBEBUILDER_ASSETS: ${{ github.workspace }}/kubebuilder/bin + - name: Logs + run: | + kubectl -n notification-system logs deploy/notification-controller + - name: Debug failure + if: failure() + run: | + kubectl -n notification-system get providers -oyaml + kubectl -n notification-system get alerts -oyaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b09283b --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,52 @@ +name: release +on: + push: + tags: + - 'v*' + +jobs: + build-push: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Kustomize + uses: ./.github/actions/kustomize + - name: Get version + id: get_version + run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//} + - name: Generate release asset + run: | + mkdir -p config/release + cp config/default/* config/release + cd config/release + kustomize edit set image fluxcd/notification-controller=fluxcd/notification-controller:${{ steps.get_version.outputs.VERSION }} + kustomize build . > notification-controller.yaml + - name: Push image + uses: docker/build-push-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + repository: fluxcd/notification-controller + tag_with_ref: true + - name: Create release + id: create_release + uses: actions/create-release@latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: false + prerelease: true + body: | + [CHANGELOG](https://github.com/fluxcd/notification-controller/blob/master/CHANGELOG.md) + - name: Upload artifacts + id: upload-release-asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: ./config/release/notification-controller.yaml + asset_name: notification-controller.yaml + asset_content_type: text/plain diff --git a/README.md b/README.md index 8188d73..e7a82df 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,8 @@ # notification-controller + +[![e2e](https://github.com/fluxcd/notification-controller/workflows/e2e/badge.svg)](https://github.com/fluxcd/notification-controller/actions) +[![report](https://goreportcard.com/badge/github.com/fluxcd/notification-controller)](https://goreportcard.com/report/github.com/fluxcd/notification-controller) +[![license](https://img.shields.io/github/license/fluxcd/notification-controller.svg)](https://github.com/fluxcd/notification-controller/blob/master/LICENSE) +[![release](https://img.shields.io/github/release/fluxcd/notification-controller/all.svg)](https://github.com/fluxcd/notification-controller/releases) + Experimental notification dispatcher diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index 6627f81..6a156c3 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -2,6 +2,7 @@ apiVersion: kustomize.config.k8s.io/v1beta1 kind: Kustomization resources: - deployment.yaml + - service.yaml images: - name: fluxcd/notification-controller newName: fluxcd/notification-controller