Skip to content

Commit

Permalink
add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
eumel8 committed Sep 4, 2023
1 parent adc6a63 commit b019dea
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,20 @@ jobs:
cosign-release: 'v2.0.0'
- name: Login Build Sign Push
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ${GHR} -u ${{ github.actor }} --password-stdin
docker login -u="${DOCKER_USERNAME}" -p="${DOCKER_PASSWORD}" ${MTR}
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
export DOCKER_BUILDKIT=1
docker build -f Dockerfile -t ${MTR}/${REPO}/${IMAGE}:${VERSION} .
docker tag ${MTR}/${REPO}/${IMAGE}:${VERSION} ghcr.io/${{ github.repository_owner }}/${IMAGE}/${IMAGE}:${VERSION}
docker tag ${MTR}/${REPO}/${IMAGE}:${VERSION} ${GHR}/${{ github.repository_owner }}/${IMAGE}/${IMAGE}:${VERSION}
docker push ${MTR}/${REPO}/${IMAGE}:${VERSION}
docker push ghcr.io/${{ github.repository_owner }}/${IMAGE}/${IMAGE}:${VERSION}
cosign sign --key env://COSIGN_KEY --tlog-upload=false ${MTR}/${REPO}/${IMAGE}:${VERSION}
cosign sign --key env://COSIGN_KEY --tlog-upload=false ghcr.io/${{ github.repository_owner }}/${IMAGE}/${IMAGE}:${VERSION}
cosign sign --key env://COSIGN_KEY --tlog-upload=false ${GHR}/${{ github.repository_owner }}/${IMAGE}/${IMAGE}:${VERSION}
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
GHR: ghcr.io
MTR: mtr.devops.telekom.de
REPO: caas
IMAGE: cosignwebhook
Expand All @@ -37,14 +38,15 @@ jobs:
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version
HELM_EXPERIMENTAL_OCI=1 helm registry login ghcr.io -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
HELM_EXPERIMENTAL_OCI=1 helm registry login ${GHR} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
HELM_EXPERIMENTAL_OCI=1 helm registry login ${MTR} -u ${DOCKER_USERNAME} -p ${DOCKER_PASSWORD}
helm lint chart
helm package chart
HELM_EXPERIMENTAL_OCI=1 helm push $(ls *.tgz| head -1) oci://ghcr.io/${{ github.actor }}/charts
HELM_EXPERIMENTAL_OCI=1 helm push $(ls *.tgz| head -1) oci://${GHR}/${{ github.actor }}/charts
HELM_EXPERIMENTAL_OCI=1 helm push $(ls *.tgz| head -1) oci://${MTR}/${REPO}/charts
env:
DOCKER_USERNAME: ${{secrets.DOCKER_USERNAME}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
GHR: ghcr.io
MTR: mtr.devops.telekom.de
REPO: caas
57 changes: 57 additions & 0 deletions .github/workflows/end2end.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
name: End2End Testing
on: [push]

jobs:
end2end:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Set up K3S
uses: debianmaster/actions-k3s@master
id: k3s
with:
version: 'v1.24.8-k3s1'
- name: Check Cluster
run: |
kubectl get nodes
- name: Setup Helm
run: |
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
helm version
- name: Install Cosignwebhook
run: |
helm -n cosignwebhook upgrade -i cosignwebhook \
--atomic \
--create-namespace \
--timeout 300s \
--set logLevel.info=debug chart
- name: Check Pods
run: |
kubectl -n cosignwebhook get pods
- name: Check Cosignwebhook Deployment
run: |
kubectl -n cosignwebhook wait --for=condition=available deployment/cosignwebhook
STATUS=$(kubectl -n cosignwebhook get deployment cosignwebhook -o jsonpath={.status.readyReplicas})
if [[ $STATUS -ne 1 ]]
then
echo "Deployment cosignwebhook not ready"
kubectl -n cosignwebhook get events
exit 1
else
echo "Deployment cosignwebhook OK"
fi
- name: Deploy Demoapp
run: |
kubectl create namespace demoapp
kubectl -n demoapp apply -f manifests/demoapp.yaml
kubectl -n demoapp wait --for=condition=available deployment/demoapp
STATUS=$(kubectl -n demoapp get deployment demoapp -o jsonpath={.status.readyReplicas})
if [[ $STATUS -ne 1 ]]
then
echo "Deployment demoapp not ready"
kubectl -n demoapp get events
exit 1
else
echo "Deployment demoapp OK"
fi
25 changes: 25 additions & 0 deletions .github/workflows/gotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go package
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.21

- name: Mod Tidy
run: go mod tidy

- name: Mod Vendor
run: go mod vendor

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...

0 comments on commit b019dea

Please sign in to comment.