Skip to content

Commit

Permalink
update actions and related stuff (#21)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Bortnikov <[email protected]>
  • Loading branch information
aobort authored Mar 6, 2024
1 parent e2f2996 commit b54cda3
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 59 deletions.
File renamed without changes.
File renamed without changes.
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
version: 2
updates:
- package-ecosystem: "gomod"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "docker"
directory: "/.docker/lifecycle-controller-manager"
schedule:
interval: "daily"
open-pull-requests-limit: 10
- package-ecosystem: "docker"
directory: "/.docker/lifecycle-service"
schedule:
interval: "daily"
open-pull-requests-limit: 10
29 changes: 29 additions & 0 deletions .github/workflows/auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Dependabot auto-approve

on: pull_request

permissions:
pull-requests: write
contents: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v1
- uses: actions/checkout@v4
- name: Setup gh cli
uses: ksivamuthu/actions-setup-gh-cli@v2
- name: Approve a Dependabot PR
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
22 changes: 0 additions & 22 deletions .github/workflows/golangci-lint.yml

This file was deleted.

183 changes: 183 additions & 0 deletions .github/workflows/pipeline.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
name: Main commit workflow

on:
workflow_dispatch:
push:
branches:
- main
tags:
- v*
paths-ignore:
- '**.md'
pull_request:
branches:
- main
paths-ignore:
- 'docs/**'
- '**/*.md'

permissions:
contents: read
packages: write


env:
platforms: linux/amd64,linux/arm64
registry: ghcr.io

jobs:
go-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Lint golang sources
uses: golangci/golangci-lint-action@v4
with:
args: -e S1008 --timeout 15m

go-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Setup golang
uses: actions/setup-go@v5
with:
go-version-file: go.mod

- name: Run tests
run: make test

docker-build-controller-manager:
needs: [ go-lint, go-test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get metadata for docker
uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/lifecycle-controller-manager
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: ${{env.platforms}}

- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
timeout-minutes: 5
uses: docker/setup-buildx-action@v3
with:
version: latest
endpoint: builders

- name: Build and push
uses: docker/build-push-action@v5
timeout-minutes: 60
with:
file: .docker/lifecycle-controller-manager/Dockerfile
context: .
platforms: ${{ env.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

docker-build-lifecycle-service:
needs: [ go-lint, go-test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get metadata for docker
uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/${{ github.repository_owner }}/lifecycle-service
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=sha
flavor: |
latest=${{ github.ref == 'refs/heads/main' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
image: tonistiigi/binfmt:latest
platforms: ${{env.platforms}}

- name: Set up Docker Context for Buildx
id: buildx-context
run: |
docker context create builders
- name: Set up Docker Buildx
timeout-minutes: 5
uses: docker/setup-buildx-action@v3
with:
version: latest
endpoint: builders

- name: Build and push
uses: docker/build-push-action@v5
timeout-minutes: 60
with:
file: .docker/lifecycle-service/Dockerfile
context: .
platforms: ${{ env.platforms }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
16 changes: 7 additions & 9 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
name: Release Drafter

on:
workflow_dispatch:
push:
branches:
- main
pull_request:
types: [ opened, reopened, synchronize ]

permissions:
contents: write
pull-requests: write

jobs:
update_release_draft:
permissions:
# write permission is required to create a github release
contents: write
# write permission is required for autolabeler
# otherwise, read permission is required at least
pull-requests: write
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "main"
- uses: release-drafter/release-drafter@v5
- uses: release-drafter/release-drafter@v6
with:
disable-releaser: github.ref != 'refs/heads/main'
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .github/workflows/size-labels.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: 'Assign size labels to PRs'

on: [workflow_dispatch, pull_request]

permissions:
contents: read
pull-requests: write

jobs:
size-label:
runs-on: ubuntu-latest
steps:
- name: size-label
uses: pascalgn/[email protected]
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
19 changes: 0 additions & 19 deletions .github/workflows/test.yml

This file was deleted.

17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
IMG ?= controller:latest
DOCKERFILE ?= .

.PHONY: fmt
fmt: goimports
Expand Down Expand Up @@ -56,12 +55,12 @@ docs: gen-crd-api-reference-docs ## Run go generate to generate API reference do

### BUILD IMAGES ###
.PHONY: docker-build-controller-manager
docker-build: ## Build docker image with the manager.
docker build . -t ${IMG}
docker-build-controller-manager: ## Build docker image with the manager.
docker build . -t ${IMG} -f .docker/lifecycle-controller-manager/Dockerfile

.PHONY: docker-build-lifecycle-service
docker-build-lcmi: ## Build docker image with the manager.
docker build . -t ${IMG} -f ${DOCKERFILE}
docker-build-lifecycle-service: ## Build docker image with the manager.
docker build . -t ${IMG} -f .docker/lifecycle-service/Dockerfile

### INSTALL AND DEPLOY ###
.PHONY: install
Expand All @@ -73,21 +72,21 @@ uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified
$(KUSTOMIZE) build config/crd | kubectl delete -f -

.PHONY: deploy-controller-manager
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy-controller-manager: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

.PHONY: undeploy-controller-manager
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
undeploy-controller-manager: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/default | kubectl delete -f -

.PHONY: deploy-lifecycle-service
deploy-lcmi: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy-lifecycle-service: kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/lcmi/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/lcmi/default | kubectl apply -f -

.PHONY: undeploy-lifecycle-service
undeploy-lcmi: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
undeploy-lifecycle-service: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/lcmi/default | kubectl delete -f -

### AUXILIARY ###
Expand Down

0 comments on commit b54cda3

Please sign in to comment.