Build and Publish nightly Helm chart and Docker images #412
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: Build and Publish nightly Helm chart and Docker images | |
on: | |
schedule: | |
- cron: "0 0 * * *" # Run every day at midnight (UTC) | |
workflow_dispatch: # Allow running manually on demand | |
env: | |
TAG: v0.0.0-${{ github.sha }} | |
REGISTRY: ghcr.io | |
PROD_ORG: rancher | |
jobs: | |
build-and-publish-ghcr: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: setupGo | |
uses: actions/setup-go@v5.1.0 | |
with: | |
go-version: '=1.22.0' | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push docker images | |
run: | | |
make docker-build-and-push TAG=${{ env.TAG }} ORG=${{ env.PROD_ORG }} | |
make docker-build-and-push-etcdrestore TAG=${{ env.TAG }} ORG=${{ env.PROD_ORG }} | |
publish-helm-chart-ghcr: | |
name: Publish Helm chart to GHCR | |
needs: | |
- build-and-publish-ghcr | |
permissions: | |
contents: read | |
packages: write | |
env: | |
HELM_EXPERIMENTAL_OCI: 1 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Install Helm | |
uses: Azure/setup-helm@v4 | |
with: | |
version: 3.8.0 | |
- name: Build Helm chart | |
run: make release-chart RELEASE_TAG=${{ env.TAG }} CONTROLLER_IMAGE_VERSION=${{ env.TAG }} | |
- name: Login to ghcr.io using Helm | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | helm registry login ghcr.io --username ${{ github.repository_owner }} --password-stdin | |
- name: Publish Helm chart to GHCR | |
env: | |
GHCR_REPOSITORY: ${{ github.repository_owner }}/rancher-turtles-chart | |
run: | | |
helm push out/package/rancher-turtles-0.0.0-${{ github.sha }}.tgz oci://ghcr.io/${{ github.repository_owner }}/rancher-turtles-chart | |
- name: Print helm install command | |
run: | | |
echo "Nightly build can be installed using the following command:" | |
echo "helm install rancher-turtles oci://ghcr.io/${{ github.repository_owner }}/rancher-turtles-chart/rancher-turtles --version 0.0.0-${{ github.sha }} -n rancher-turtles-system --create-namespace --wait" |