Workflow file for this run
This file contains hidden or 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: Build and Push ArgoCD Controller | |
on: | |
push: | |
branches: | |
- tk/argocd | |
workflow_dispatch: | |
inputs: | |
argo_version: | |
description: 'ArgoCD version to package' | |
required: true | |
default: '7.8.8' | |
upbound_org: | |
description: 'Upbound organization name' | |
required: true | |
controller_version: | |
description: 'Version for the controller package' | |
required: true | |
default: 'v7.8.8' | |
push_to_registry: | |
description: 'Push package to registry' | |
type: boolean | |
default: true | |
env: | |
CHART_REPOSITORY: https://argoproj.github.io/argo-helm | |
CHART_NAME: argo-cd | |
RELEASE_NAME: argo-cd | |
RELEASE_NAMESPACE: argo-system | |
CONTROLLER_NAME: controller-argocd | |
jobs: | |
build-controller: | |
name: Build ArgoCD Controller Package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Helm | |
uses: azure/setup-helm@v3 | |
with: | |
version: 'latest' | |
- name: Set up Kubernetes | |
uses: azure/setup-kubectl@v4 | |
- name: Install yq | |
run: | | |
wget https://github.com/mikefarah/yq/releases/download/v4.35.1/yq_linux_amd64 -O /usr/local/bin/yq | |
chmod +x /usr/local/bin/yq | |
- name: Install up CLI | |
run: | | |
curl -sL "https://cli.upbound.io" | sh | |
sudo mv up /usr/local/bin/ | |
up version | |
- name: Create working directory | |
run: | | |
mkdir -p controller-package | |
cd controller-package | |
- name: Set version variables | |
run: | | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
echo "ARGO_VERSION=${{ github.event.inputs.argo_version }}" >> $GITHUB_ENV | |
echo "CONTROLLER_VERSION=${{ github.event.inputs.controller_version }}" >> $GITHUB_ENV | |
echo "UPBOUND_ORG=${{ github.event.inputs.upbound_org }}" >> $GITHUB_ENV | |
echo "PUSH_TO_REGISTRY=${{ github.event.inputs.push_to_registry }}" >> $GITHUB_ENV | |
else | |
echo "ARGO_VERSION=7.8.8" >> $GITHUB_ENV | |
echo "CONTROLLER_VERSION=v7.8.8" >> $GITHUB_ENV | |
echo "UPBOUND_ORG=${{ secrets.UPBOUND_ORG }}" >> $GITHUB_ENV | |
echo "PUSH_TO_REGISTRY=false" >> $GITHUB_ENV | |
fi | |
- name: Pull Helm chart | |
working-directory: controller-package | |
run: | | |
helm pull ${{ env.CHART_NAME }} --repo ${{ env.CHART_REPOSITORY }} --version ${{ env.ARGO_VERSION }} | |
- name: Setup controller package structure | |
working-directory: controller-package | |
run: | | |
# Create helm directory and move chart | |
mkdir -p helm | |
mv ${{ env.CHART_NAME }}-${{ env.ARGO_VERSION }}.tgz helm/chart.tgz | |
# Extract CRDs | |
mkdir -p crds | |
helm template ${{ env.RELEASE_NAME }} helm/chart.tgz -n ${{ env.RELEASE_NAMESPACE }} --include-crds --kube-version=1.25.0 | \ | |
yq e 'select(.kind == "CustomResourceDefinition")' - | \ | |
yq -s '("crds/" + .metadata.name + ".yaml")' - | |
# Create crossplane.yaml | |
cat <<EOF > crossplane.yaml | |
apiVersion: meta.pkg.upbound.io/v1alpha1 | |
kind: Controller | |
metadata: | |
annotations: | |
friendly-name.meta.crossplane.io: Controller ArgoCD | |
meta.crossplane.io/description: | | |
The ArgoCD Controller enables continuous delivery and declarative configuration | |
management for Kubernetes applications using GitOps principles. | |
meta.crossplane.io/license: Apache-2.0 | |
meta.crossplane.io/maintainer: Upbound Maintainers <info@upbound.io> | |
meta.crossplane.io/readme: | | |
ArgoCD is a declarative GitOps continuous delivery tool for Kubernetes that | |
follows the GitOps methodology to manage infrastructure and application | |
configurations. | |
meta.crossplane.io/source: https://github.com/argoproj/argo-cd | |
name: argocd | |
spec: | |
packagingType: Helm | |
helm: | |
releaseName: ${{ env.RELEASE_NAME }} | |
releaseNamespace: ${{ env.RELEASE_NAMESPACE }} | |
EOF | |
# List the structure for verification | |
find . -type f | sort | |
- name: Build xpkg | |
working-directory: controller-package | |
run: up xpkg build | |
- name: Find xpkg file | |
id: find-xpkg | |
working-directory: controller-package | |
run: | | |
XPKG_FILE=$(find . -name "*.xpkg" -type f -printf "%f\n") | |
echo "XPKG_FILE=${XPKG_FILE}" >> $GITHUB_ENV | |
echo "xpkg_file=${XPKG_FILE}" >> $GITHUB_OUTPUT | |
- name: Push to registry | |
working-directory: controller-package | |
run: | | |
# Login to Upbound Registry | |
up login -t "${{ secrets.UP_API_TOKEN }}" -a "${{ env.UPBOUND_ORG }}" | |
# Push the package | |
up xpkg push --create xpkg.upbound.io/${{ env.UPBOUND_ORG }}/${{ env.CONTROLLER_NAME }}:${{ env.CONTROLLER_VERSION }} -f ${{ env.XPKG_FILE }} | |
- name: Upload xpkg artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: argocd-controller-package | |
path: controller-package/*.xpkg | |
retention-days: 7 | |
- name: Create deployment manifest | |
run: | | |
cat <<EOF > deploy-argocd-controller.yaml | |
apiVersion: pkg.upbound.io/v1alpha1 | |
kind: Controller | |
metadata: | |
name: ${{ env.CONTROLLER_NAME }} | |
spec: | |
package: xpkg.upbound.io/${{ env.UPBOUND_ORG }}/${{ env.CONTROLLER_NAME }}:${{ env.CONTROLLER_VERSION }} | |
EOF | |
- name: Upload deployment manifest | |
uses: actions/upload-artifact@v4 | |
with: | |
name: deployment-manifest | |
path: deploy-argocd-controller.yaml | |
retention-days: 7 |