Skip to content

Commented delete namespace #27

Commented delete namespace

Commented delete namespace #27

Workflow file for this run

name: CI
on:
push:
branches:
- develop
- release*
tags: [v*]
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
pull_request:
# Sequence of patterns matched against refs/heads
branches:
- develop
- release*
paths-ignore:
- README.md
- CHANGELOG.md
- LICENSE
env:
PROJECT: 'focal-freedom-236620'
IMAGE_NAME: 'operator'
GKE_CLUSTER: 'iofogctl-ci'
GKE_ZONE: 'us-central1-a'
jobs:
Operator:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
packages: 'write'
name: Operator
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-go@v4
with:
go-version: '1.19'
- run: go version
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.50.1
args: --timeout=5m0s
- uses: azure/setup-kubectl@v3
id: install
- name: Set up Kustomize
run: |-
curl -sfLo kustomize https://github.com/kubernetes-sigs/kustomize/releases/download/v3.1.0/kustomize_3.1.0_linux_amd64
chmod u+x ./kustomize
- run: sudo make bats
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
with:
fallback: 0.0.0
- name: Set image tag
shell: bash
id: tags
run: |
if [[ ${{ github.ref_name }} =~ ^v.* ]] ; then
VERSION=${{ github.ref_name }}
echo "VERSION=${VERSION:1}" >> "${GITHUB_OUTPUT}"
else
VERSION=${{ steps.previoustag.outputs.tag }}
echo "VERSION=${VERSION:1}-${{ github.run_number }}" >> "${GITHUB_OUTPUT}"
fi
- name: Get image tag
run: |
echo ${{ steps.tags.outputs.VERSION }}
- uses: google-github-actions/setup-gcloud@94337306dda8180d967a56932ceb4ddcf01edae7
with:
service_account_key: ${{ secrets.GKE_SA_KEY }}
project_id: ${{ env.PROJECT }}
# Get the GKE credentials so we can deploy to the cluster
- uses: google-github-actions/get-gke-credentials@fb08709ba27618c31c09e014e1d8364b02e5042e
with:
cluster_name: ${{ env.GKE_CLUSTER }}
location: ${{ env.GKE_ZONE }}
credentials: ${{ secrets.GKE_SA_KEY }}
- name: Login to Github Container Registry
uses: docker/login-action@v2
with:
registry: "ghcr.io"
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Build and Push to ghcr
uses: docker/build-push-action@v3
id: build_push_ghcr
with:
file: './Dockerfile'
push: true
tags: |
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:${{ steps.tags.outputs.VERSION }}
ghcr.io/eclipse-iofog/${{ env.IMAGE_NAME }}:latest
context: './'
- name: Build and Push to GCR
if: ${{ steps.tags.outcome }} == 'success'
id: build_push_gcr
uses: RafikFarhad/push-to-gcr-github-action@v5-beta
with:
gcloud_service_key: ${{ secrets.GCLOUD_SERVICE_KEY }}
registry: gcr.io
project_id: ${{ env.PROJECT }}
image_name: ${{ env.IMAGE_NAME }}
image_tag: latest, ${{ steps.tags.outputs.VERSION }}
dockerfile: './Dockerfile'
context: './'
- name: Kustomize
shell: bash
run: |
set -e
IMAGE="gcr.io/focal-freedom-236620/operator:${{ steps.tags.outputs.VERSION }}"
cd config/operator
kustomize edit set image "$IMAGE"
kustomize build . > /tmp/deployment.yaml
cp /tmp/deployment.yaml ./deployment.yaml
cat ./deployment.yaml | grep "image: $IMAGE"
- name: Feature tests
shell: bash
id: feature_test
run: |
set -e
cp test/conf/env.sh.tpl test/conf/env.sh
sed -i "s/<<NAMESPACE>>/${{ github.run_number }}/g" test/conf/env.sh
sed -i "s/<<OP_VERSION>>/${{ steps.tags.outputs.VERSION }}/g" test/conf/env.sh
make feature
# - name: Cleanup tests
# if: failure() && steps.feature_test.outcome == 'failure'
# shell: bash
# run: |
# set -e
# kubectl delete ns ${{ github.run_number }}
- run: mkdir -p ${{ github.workspace }}/artifact
- run: echo ${{ steps.tags.outputs.VERSION }} > ${{ github.workspace }}/artifact/version.txt
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: operator
path: ${{ github.workspace }}/artifact/version.txt