From cd1fd88088a4bc41883d1bcc827907948740372a Mon Sep 17 00:00:00 2001 From: Avital Tamir Date: Tue, 10 Sep 2024 11:17:35 +0300 Subject: [PATCH] Add workflows for PR and release --- .github/workflows/pr-checks.yml | 23 ++++++++++++++ .github/workflows/release.yml | 56 +++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/pr-checks.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml new file mode 100644 index 00000000..a70c000f --- /dev/null +++ b/.github/workflows/pr-checks.yml @@ -0,0 +1,23 @@ +name: PR Checks + +on: + pull_request: + branches: [ main ] + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + - name: Install goyacc + run: go install golang.org/x/tools/cmd/goyacc@latest + - name: Run tests + run: make test + - name: Run operator tests + run: make operator-test + - name: Build operator docker image + run: make -C operator docker-build \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..0b887dc4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,56 @@ +name: Release + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.22' + - name: Install goyacc + run: go install golang.org/x/tools/cmd/goyacc@latest + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Extract version + id: get_version + run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT + - name: Build and push operator image + env: + IMG: fatliverfreddy/cyphernetes-operator:${{ steps.get_version.outputs.VERSION }} + run: | + make -C operator docker-build IMG=$IMG + docker push $IMG + docker tag $IMG fatliverfreddy/cyphernetes-operator:latest + docker push fatliverfreddy/cyphernetes-operator:latest + - name: Set up Helm + uses: azure/setup-helm@v3 + with: + version: v3.12.0 + - name: Package and push Helm chart + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + helm package operator/helm/cyphernetes-operator + echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io -u ${{ github.actor }} --password-stdin + helm push cyphernetes-operator-*.tgz oci://ghcr.io/${{ github.repository }}/charts + - name: Create Release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: Release ${{ github.ref }} + draft: false + prerelease: false \ No newline at end of file