style: pre-commit autoupdate #162
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: Packaging | |
on: | |
release: | |
types: [published] | |
pull_request: | |
push: | |
branches: [main] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
container-image: | |
name: Container Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Assemble metadata | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ghcr.io/${{ github.repository }} | |
# We want to set the following tags: | |
# - `main` if executed for build on main branch | |
# - SemVer when running for a release | |
tags: | | |
type=ref,enable=${{ github.ref_name == 'main' }},event=branch | |
type=semver,pattern={{version}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}} | |
- name: Login to GitHub container registry | |
# We only need to log in if we want to push to GHCR | |
if: github.event_name == 'release' || github.event_name == 'push' | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ github.token }} | |
- name: Build multi-platform image | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
# Only push when building for a tag or the main branch | |
push: ${{ github.event_name == 'release' || github.event_name == 'push' }} | |
tags: ${{ steps.meta.outputs.tags }} | |
# Only export and upload the image if used for testing | |
- name: Export image for test platform | |
if: github.event_name != 'release' | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
push: false | |
outputs: type=docker,dest=/tmp/image.tar | |
- name: Upload image for testing | |
uses: actions/upload-artifact@v4 | |
if: github.event_name != 'release' | |
with: | |
name: docker-image | |
path: /tmp/image.tar | |
helm-chart: | |
name: Helm Chart | |
if: github.event_name == 'release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Helm | |
uses: azure/setup-helm@v4 | |
- name: Login to GitHub OCI Registry | |
run: | | |
echo ${{ github.token }} | \ | |
helm registry login ghcr.io --username ${{ github.actor }} --password-stdin | |
- name: Download Dependencies | |
run: helm dependency build | |
working-directory: ./chart | |
- name: Package Chart | |
run: | | |
VERSION=${{ github.ref_name }} | |
helm package . \ | |
--app-version ${VERSION#v} \ | |
--version ${VERSION#v} | |
working-directory: ./chart | |
- name: Push Chart | |
run: | | |
VERSION=${{ github.ref_name }} | |
helm push switchboard-${VERSION#v}.tgz oci://ghcr.io/${{ github.actor }}/charts | |
working-directory: ./chart | |
e2e-tests: | |
name: End-to-end Tests | |
if: github.event_name != 'release' | |
needs: container-image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Docker buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "16" | |
- name: Install bats | |
run: npm install -g bats@1.6.0 | |
shell: bash | |
- name: Download image for testing | |
uses: actions/download-artifact@v4 | |
with: | |
name: docker-image | |
path: /tmp | |
- name: Setup just | |
uses: extractions/setup-just@v2 | |
- name: Setup Kubernetes cluster | |
uses: container-tools/kind-action@v2.0.4 | |
with: | |
config: tests/config/kind.yaml | |
- name: Import Docker image | |
run: | | |
IMAGE_ID=$(docker load -i /tmp/image.tar | rev | cut -d' ' -f1 | rev) | |
docker tag $IMAGE_ID $KIND_REGISTRY/switchboard:dev | |
docker push $KIND_REGISTRY/switchboard:dev | |
- name: Run tests | |
run: just e2e-test-ci "${{ env.KIND_REGISTRY }}/switchboard" "dev" |