Build and Publish nightly Helm chart and Docker images #30
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_REGISTRY: ${{ secrets.REGISTRY_ENDPOINT }} | |
PROD_USERNAME: ${{ secrets.REGISTRY_USERNAME }} | |
PROD_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }} | |
PROD_ORG: rancher-sandbox | |
jobs: | |
build-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@v4 | |
with: | |
go-version: '=1.20.7' | |
- name: Docker login | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build docker image | |
run: make docker-build-all TAG=${{ env.TAG }} | |
- name: Push docker image | |
run: make docker-push-all TAG=${{ env.TAG }} | |
publish-helm-chart-ghcr: | |
name: Publish Helm chart to GHCR | |
needs: | |
- build-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@v3 | |
with: | |
version: 3.8.0 | |
- name: Build Helm chart | |
run: make release-chart RELEASE_TAG=v0.0.0-${{ github.sha }} | |
- 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 | |
publish-ghcr-helm-chart-oci-image: | |
name: Publish GHCR Helm chart as OCI image | |
needs: | |
- publish-helm-chart-ghcr | |
permissions: | |
contents: read | |
packages: write | |
env: | |
GHCR_REPOSITORY: ${{ github.repository_owner }}/rancher-turtles-chart | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ github.ref }} | |
- name: Install Helm | |
uses: Azure/setup-helm@v3 | |
with: | |
version: 3.8.0 | |
- name: Publish Helm chart as OCI image to ghcr | |
run: | | |
helm chart export out/package/rancher-turtles-0.0.0-${{ github.sha }}.tgz oci://ghcr.io/${{ github.repository_owner }}/rancher-turtles-chart | |
build-and-publish-prod: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: '=1.20.7' | |
- name: Docker login to prod registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ secrets.PROD_REGISTRY_ENDPOINT }} | |
username: ${{ secrets.PROD_REGISTRY_USERNAME }} | |
password: ${{ secrets.PROD_REGISTRY_PASSWORD }} | |
- name: Build Docker image for prod registry | |
run: make docker-build-all TAG=${{ env.TAG }} REGISTRY=${{ secrets.PROD_REGISTRY_ENDPOINT }} ORG=${{ secrets.PROD_ORG }} | |
- name: Push Docker image to prod registry | |
run: make docker-push-all TAG=${{ env.TAG }} REGISTRY=${{ secrets.PROD_REGISTRY_ENDPOINT }} ORG=${{ secrets.PROD_ORG }} | |
build-and-publish-prod-helm-chart-oci-image: | |
name: Build Helm Chart and publish as OCI image to prod registry | |
needs: | |
- build-and-publish-prod | |
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@v3 | |
with: | |
version: 3.8.0 | |
- name: Build Helm chart | |
run: make release-chart RELEASE_TAG=${{ env.TAG }} | |
- name: Login to prod registry using Helm | |
run: | | |
echo ${{ secrets.PROD_REGISTRY_PASSWORD }} | helm registry login ${{ secrets.PROD_REGISTRY_ENDPOINT }} --username ${{ secrets.PROD_REGISTRY_USERNAME }} --password-stdin | |
- name: Publish Helm chart as OCI image to prod registry | |
run: | | |
helm push out/package/rancher-turtles-0.0.0-${{ github.sha }}.tgz oci://$${{ secrets.PROD_REGISTRY_ENDPOINT }}/$${{ secrets.PROD_ORG }}/rancher-turtles-chart |