Skip to content

Merge pull request #99 from vmware-tanzu/revert-92-dependabot/github_… #46

Merge pull request #99 from vmware-tanzu/revert-92-dependabot/github_…

Merge pull request #99 from vmware-tanzu/revert-92-dependabot/github_… #46

Workflow file for this run

name: ci
on:
push:
branches:
- main
- release/**
tags:
- v[0-9]+.[0-9]+.[0-9]+-?**
pull_request:
branches:
- release/**
defaults:
run:
shell: bash
env:
PUBLIC_IMAGE_DEV_REPO: ${{ vars.PUBLIC_IMAGE_DEV_REPO }}
PUBLIC_IMAGE_REPO: ${{ vars.PUBLIC_IMAGE_REPO }}
PACK_VERSION: ${{ vars.PACK_VERSION }}
jobs:
unit:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Run tests
run: go test -v ./pkg/...
- name: Report coverage
uses: codecov/codecov-action@v3.1.4
webhook-image:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
image: ${{ steps.build.outputs.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: ./.github/actions/docker-login
with:
registry: ${{ env.PUBLIC_IMAGE_DEV_REPO }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build
id: build
uses: ./.github/actions/pack-build
with:
pack_version: ${{ env.PACK_VERSION }}
tag: ${{ env.PUBLIC_IMAGE_DEV_REPO }}/webhook
bp_go_targets: "./cmd/webhook"
setup-ca-certs-image:
runs-on: ubuntu-latest
outputs:
digest: ${{ steps.build.outputs.digest }}
image: ${{ steps.build.outputs.image }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker Login
uses: ./.github/actions/docker-login
with:
registry: ${{ env.PUBLIC_IMAGE_DEV_REPO }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build
id: build
uses: ./.github/actions/pack-build
with:
pack_version: ${{ env.PACK_VERSION }}
tag: ${{ env.PUBLIC_IMAGE_DEV_REPO }}/setup-ca-certs
bp_go_targets: "./cmd/setup-ca-certs"
builder: "paketobuildpacks/builder-jammy-base"
bundle:
runs-on: ubuntu-latest
needs:
- webhook-image
- setup-ca-certs-image
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Docker Login
uses: ./.github/actions/docker-login
with:
registry: ${{ env.PUBLIC_IMAGE_DEV_REPO }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Setup carvel
uses: carvel-dev/setup-action@v2
with:
token: ${{ secrets.RELEASE_TOKEN }}
only: ytt, kbld, imgpkg
- name: imgpkg push
uses: ./.github/actions/imgpkg-push
with:
webhook_image: ${{ needs.webhook-image.outputs.image }}
setup_ca_certs_image: ${{ needs.setup-ca-certs-image.outputs.image }}
bundle_output: pre-release-bundle.lock
tag: ${{ env.PUBLIC_IMAGE_DEV_REPO }}/bundle
e2e:
needs:
- bundle
- webhook-image
- setup-ca-certs-image
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Setup crane
uses: imjasonh/setup-crane@v0.3
- name: Setup carvel
uses: carvel-dev/setup-action@v2
with:
token: ${{ secrets.RELEASE_TOKEN }}
only: ytt, kapp, imgpkg, kbld
- name: Download bundle lock
uses: actions/download-artifact@v3
with:
name: pre-release-bundle.lock
- name: Create Kind Cluster
uses: helm/kind-action@v1.8.0
with:
cluster_name: e2e
- name: Deploy
run: |
cat <<EOT > test-values.yaml
---
labels:
- some-label-1
- some-label-2
annotations:
- some-annotation-1
- some-annotation-2
EOT
imgpkg pull --lock pre-release-bundle.lock --output pulled-bundle
ytt -f pulled-bundle/config --data-values-file test-values.yaml \
| kbld -f- -f pulled-bundle/.imgpkg/images.yml \
| kapp deploy -a cert-injection-webhook -f- -y
- name: Run Tests
run: go test --timeout=30m -v ./e2e/...
release:
needs:
- unit
- e2e
- bundle
- webhook-image
- setup-ca-certs-image
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Setup crane
uses: imjasonh/setup-crane@v0.3
- name: Setup carvel
uses: carvel-dev/setup-action@v2
with:
token: ${{ secrets.RELEASE_TOKEN }}
only: ytt, kbld, imgpkg
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Docker Login
uses: ./.github/actions/docker-login
with:
registry: ${{ env.PUBLIC_IMAGE_REPO }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Validate release version
run: |
echo "GITHUB_REF=${GITHUB_REF}"
[[ $GITHUB_REF =~ ^refs\/tags\/v(.*)$ ]] && version=${BASH_REMATCH[1]}
if [[ -z "${version}" ]]; then
echo "ERROR: version not detected."
exit 1
fi
- name: Promote images
id: promote
run: |
mkdir -p final-image-refs
for image in images/*; do
dev_image=$(cat $image)
digest=$(echo $dev_image| cut -d "@" -f 2)
name=$(basename $image)
final_repo="${{ env.PUBLIC_IMAGE_REPO }}/${name}"
crane copy "$dev_image" "$final_repo"
echo "${final_repo}@${digest}" > final-image-refs/$name
echo "$name=$(cat final-image-refs/$name)" >> $GITHUB_OUTPUT
done
- name: Upload image refs
uses: actions/upload-artifact@v3
with:
name: final-image-refs
path: final-image-refs/*
- name: imgpkg push
uses: ./.github/actions/imgpkg-push
with:
webhook_image: ${{ steps.promote.outputs.webhook }}
setup_ca_certs_image: ${{ steps.promote.outputs.setup-ca-certs }}
bundle_output: release-bundle.lock
tag: ${{ env.PUBLIC_IMAGE_REPO }}/bundle
- name: tar config
run: |
tar -C imgpkg-bundle -cvzf config.tar.gz config
- name: Upload bundle
uses: actions/upload-artifact@v3
with:
name: config
path: config.tar.gz
- name: Create Draft Release
uses: softprops/action-gh-release@v1
with:
name: cert-injection-webhook v${{ env.VERSION }}
tag_name: v${{ env.VERSION }}
target_commitish: ${{ github.sha }}
token: ${{ secrets.RELEASE_TOKEN }}
draft: true
prerelease: true
generate_release_notes: true
files: |
release-bundle.lock
config.tar.gz
final-image-refs/*