Skip to content

Commit

Permalink
chore: ci/cd
Browse files Browse the repository at this point in the history
Signed-off-by: Ievgenii Shepeliuk <[email protected]>
  • Loading branch information
eshepelyuk committed May 7, 2022
1 parent 0ff92fc commit 2d3b6e9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,48 @@ on:

jobs:
docker_job:
name: Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: volesen/[email protected]
with:
version: 'v1.38.0'
- uses: extractions/setup-just@v1
- name: Calculate release version
- name: release version
id: theVersion
run: echo "::set-output name=theVersion::$(echo ${GITHUB_REF##*/})"
- name: Login to DockerHub
- name: login to dockerhub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build docker image
- name: build and publish image, create chart archive
run: |
just VERSION=${{ steps.theVersion.outputs.theVersion }} build-release
- name: Upload Helm artifact
- name: upload helm artifact
uses: actions/upload-artifact@v2
with:
name: "helm"
path: "opa-${{ steps.theVersion.outputs.theVersion }}.tgz"

helm_job:
name: Helm chart
runs-on: ubuntu-latest
needs: docker_job
steps:
- uses: actions/checkout@v2
with:
ref: gh-pages
- name: Download artifact from build job
- name: download helm artifact
uses: actions/download-artifact@v2
id: download
with:
name: helm
path: /tmp/helm
- name: Update Helm index
- name: update helm index
run: |
helm repo index /tmp/helm --merge ./charts/index.yaml
mv -f /tmp/helm/* ./charts
- name: Publish index and chart to gh-pages
- name: publish index and chart
uses: actions-js/push@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
26 changes: 16 additions & 10 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,29 @@ export COMMIT := `git rev-parse --short HEAD`
export VERSION := "0.0.0-" + COMMIT
export E2E_TEST := "default"

skaffoldTags := "tags.json"

defaul:
@just --list

@_skaffold-ctx:
skaffold config set default-repo localhost:5000

# build and publish image to release regisry, create chart archive
build-release:
#!/usr/bin/env bash
set -euxo pipefail
skaffold build -b kube-mgmt -t {{VERSION}} --file-output=tags.json
helm package charts/opa --version {{VERSION}} --app-version {{VERSION}}
skaffold build -b kube-mgmt -t {{VERSION}} --file-output={{skaffoldTags}}
LATEST="$(jq -r .builds[0].imageName {{skaffoldTags}}):latest"
CURRENT="$(jq -r .builds[0].tag {{skaffoldTags}})"

LATEST="$(jq -r .builds[0].imageName skaffold.json):latest"
CURRENT="$(jq -r .builds[0].tag skaffold.json)"
docker tag $CURRENT $LATEST
docker push $LATEST

@test-go:
helm package charts/opa --version {{VERSION}} --app-version {{VERSION}}

test-go:
go test ./...
go vet ./...
staticcheck ./...
Expand All @@ -35,18 +40,19 @@ k3d: && _skaffold-ctx
k3d cluster delete kube-mgmt || true
k3d cluster create --config ./test/e2e/k3d.yaml

build:
skaffold build --file-output=tags.json --platform=linux/amd64
# build and publish docker to local registry
build: _skaffold-ctx
skaffold build --file-output={{skaffoldTags}} --platform=linux/amd64

# install into local k8s
up: _skaffold-ctx down
skaffold deploy --build-artifacts=tags.json
skaffold deploy --build-artifacts={{skaffoldTags}}

# remove from local k8s
down:
skaffold delete || true

# run only e2e test script
# run only e2e test script
test-e2e-sh:
kubectl delete cm -l kube-mgmt/e2e=true || true
./test/e2e/{{E2E_TEST}}/test.sh
Expand All @@ -59,5 +65,5 @@ test-e2e-all: build
#!/usr/bin/env bash
set -euxo pipefail
for E in $(find test/e2e/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n'); do
just E2E_TEST=${E} test-e2e
just E2E_TEST=${E} test-e2e
done

0 comments on commit 2d3b6e9

Please sign in to comment.