From 26a4d142d7de8699d6edf0095f080ae6abe971e5 Mon Sep 17 00:00:00 2001 From: Ryan Cavicchioni Date: Tue, 6 May 2025 00:14:48 -0500 Subject: [PATCH] break Gitea actions up into separate files --- .gitea/workflows/ci.yaml | 42 ------------- .gitea/workflows/lint.yaml | 23 +++++++ .gitea/workflows/release.yaml | 112 ++++++++++++++++++++++++++++++++++ .gitea/workflows/test.yaml | 22 +++++++ 4 files changed, 157 insertions(+), 42 deletions(-) create mode 100644 .gitea/workflows/lint.yaml create mode 100644 .gitea/workflows/release.yaml create mode 100644 .gitea/workflows/test.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml index 4a5867a..5cd8e56 100644 --- a/.gitea/workflows/ci.yaml +++ b/.gitea/workflows/ci.yaml @@ -13,48 +13,6 @@ on: pull_request: jobs: - lint: - runs-on: ubuntu-latest - permissions: - checks: write - contents: write - steps: - - name: Login to Docker - uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 - with: - username: ${{ vars.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Ruby Setup - uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0 - with: - ruby-version: '3.4' - bundler-cache: true - - - run: bundle install - - - name: Standard Ruby - run: bundle exec standardrb - - - test: - needs: lint - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 - - - name: Test - uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0 - with: - ruby-version: '3.4' - bundler-cache: true - - - run: bundle exec rake - docker: needs: test runs-on: ubuntu-latest diff --git a/.gitea/workflows/lint.yaml b/.gitea/workflows/lint.yaml new file mode 100644 index 0000000..1e01ace --- /dev/null +++ b/.gitea/workflows/lint.yaml @@ -0,0 +1,23 @@ +--- +name: Ruby Lint +on: + push: + branches: + - "**" + pull_request: +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Ruby Setup + uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0 + with: + ruby-version: '3.4' + bundler-cache: true + + - name: Standard Ruby + run: bundle exec standardrb + diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml new file mode 100644 index 0000000..41a6c47 --- /dev/null +++ b/.gitea/workflows/release.yaml @@ -0,0 +1,112 @@ +--- +name: Gitea Actions Demo + +on: + schedule: + - cron: "0 10 * * *" + push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: + +jobs: + docker: + runs-on: ubuntu-latest + container: + image: catthehacker/ubuntu:act-latest + env: + DOCKER_ORG: ryanc + DOCKER_LATEST: latest + defaults: + run: + shell: bash + outputs: + metadata: ${{ steps.output.outputs.metadata }} + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 # all history for all branches and tags + + - name: Prepare + id: prep + run: | + VERSION="sha-${GITHUB_SHA::8}" + if [[ "$GITHUB_REF" == refs/tags/* ]]; then + VERSION="${GITHUB_REF/refs\/tags\//}" + fi + printf "GITHUB_REF=%s\n" "$GITHUB_REF" + printf "GITHUB_SHA=%s\n" "$GITHUB_SHA" + printf "VERSION=%s\n" "$VERSION" | tee -a "$GITHUB_OUTPUT" + + - name: Set up QEMU + uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0 + + - name: Login to Gitea registry + uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0 + with: + registry: git.kill0.net + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Docker meta (debian) + id: meta + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 + with: + images: | + git.kill0.net/ryanc/kubernaut + flavor: | + latest=auto + bake-target: docker-metadata-action + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Docker meta (alpine) + id: meta-alpine + uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # v5.7.0 + with: + images: | + git.kill0.net/ryanc/kubernaut + bake-target: docker-metadata-action-alpine + flavor: | + latest=auto + suffix=-alpine,onlatest=true + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: Docker build and push + uses: docker/bake-action@76f9fa3a758507623da19f6092dc4089a7e61592 # v6.6.0 + with: + push: ${{ github.event_name != 'pull_request' }} + files: | + ./docker-bake.hcl + cwd://${{ steps.meta.outputs.bake-file }} + cwd://${{ steps.meta-alpine.outputs.bake-file }} + + - name: Setup Helm + uses: azure/setup-helm@b9e51907a09c216f16ebe8536097933489208112 # v4.3.0 + + - name: Publish Helm chart + if: ${{ contains(github.ref, 'refs/tags/') }} + run: | + HELM_VERSION="${{ steps.prep.outputs.VERSION }}" + HELM_VERSION="${HELM_VERSION#v}" + helm package charts/kubernaut + helm push "kubernaut-${HELM_VERSION}.tgz" oci://git.kill0.net/ryanc/helm-charts diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml new file mode 100644 index 0000000..80134a8 --- /dev/null +++ b/.gitea/workflows/test.yaml @@ -0,0 +1,22 @@ +--- +name: Ruby Test +on: + push: + branches: + - "**" + pull_request: +jobs: + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + - name: Test + uses: ruby/setup-ruby@dffc446db9ba5a0c4446edb5bca1c5c473a806c5 # v1.235.0 + with: + ruby-version: '3.4' + bundler-cache: true + + - run: bundle exec rake +