release-pipeline #2
This file contains 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: release-pipeline | |
on: | |
create: | |
tags: | |
- '**' | |
jobs: | |
pre-checks: | |
runs-on: ubuntu-latest | |
steps: | |
# Install golang | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: 1.20.0 | |
# Checkout to the latest commit | |
# On specific directory/path | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: gofmt check | |
run: make gofmt-check | |
- name: golangci-lint | |
uses: reviewdog/action-golangci-lint@v1 | |
- name: unused-package check | |
run: make unused-package-check | |
image-build: | |
runs-on: ubuntu-latest | |
needs: tests | |
steps: | |
# Checkout to the latest commit | |
# On specific directory/path | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v1 | |
with: | |
platforms: all | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v1 | |
with: | |
version: latest | |
- name: login to GitHub Container Registry | |
run: echo ${{ secrets.DPASS }} | docker login -u ${{ secrets.DNAME }} --password-stdin | |
- name: Set Tag | |
run: | | |
TAG="${GITHUB_REF#refs/*/}" | |
echo "TAG=${TAG}" >> $GITHUB_ENV | |
echo "RELEASE_TAG=${TAG}" >> $GITHUB_ENV | |
- name: Build & Push Docker Image with version tag | |
env: | |
DOCKER_REPO: ${{ secrets.DOCKER_REPO }} | |
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }} | |
DOCKER_TAG: ${RELEASE_TAG} | |
DNAME: ${{ secrets.DNAME }} | |
DPASS: ${{ secrets.DPASS }} | |
run: make push-chaos-operator | |
- name: Build & Push Docker Image with latest | |
env: | |
DOCKER_REPO: ${{ secrets.DOCKER_REPO }} | |
DOCKER_IMAGE: ${{ secrets.DOCKER_IMAGE }} | |
DOCKER_TAG: latest | |
DNAME: ${{ secrets.DNAME }} | |
DPASS: ${{ secrets.DPASS }} | |
run: make push-chaos-operator | |
tests: | |
needs: pre-checks | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout to the latest commit | |
# On specific directory/path | |
- name: Checkout | |
uses: actions/checkout@v2 | |
# Install golang | |
- uses: actions/setup-go@v2 | |
with: | |
go-version: 1.20.0 | |
#Install and configure a kind cluster | |
- name: Installing Prerequisites (K3S Cluster) | |
env: | |
KUBECONFIG: /etc/rancher/k3s/k3s.yaml | |
run: | | |
curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.20.14-rc1+k3s1 sh -s - --docker --write-kubeconfig-mode 664 | |
kubectl wait node --all --for condition=ready --timeout=90s | |
mkdir -p $HOME/.kube | |
cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config | |
kubectl get nodes | |
- name: Dependency checks | |
run: | | |
make deps | |
- name: Build Docker Image | |
env: | |
DOCKER_REPO: litmuschaos | |
DOCKER_IMAGE: chaos-operator | |
DOCKER_TAG: ci | |
run: | | |
make build-amd64 | |
- name: Running Go BDD Test | |
run: | | |
make test |